乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Spring整合Junit

       Coder編程 2020-05-31

      一. 導(dǎo)入相關(guān)依賴

      (1) junit依賴

          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
          </dependency>
      

      注:Spring 5.x 版本整合Junit時(shí),Junit的版本要求必須在4.12及以上,否則會(huì)報(bào)錯(cuò)

      Spring整合Junit版本問題

      (2)spring-test

          <!--Spring-test-->
          <!-- https:///artifact/org.springframework/spring-aspects -->
          <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.0.2.RELEASE</version>
          </dependency>
      

      二. 添加注解

      在測(cè)試類添加注解:

      /**
      	* RunWith注解:
      	* 作用: 把原有的main方法替換成spring提供的main方法
      	* 寫法固定
      	*/
      @RunWith(SpringJUnit4ClassRunner.class)
      /**
         * ContextConfiguration注解:
         * locations屬性: 用于指定Spring配置文件的路徑
         * classes屬性: 用于指定注解類所在地的路徑
         */
      @ContextConfiguration(locations = {"classpath:applicationContext.xml"})
      // 注解類寫法:
      //@ContextConfiguration(classes = SpringConfiguration.class)
      public class MapperTest {
      	//實(shí)現(xiàn)自動(dòng)依賴注入
          @Autowired
          private DepartmentMapper departmentMapper;
      
          @Test
          public void testCRUD(){
              //使用依賴注入的對(duì)象
              System.out.println(departmentMapper);
          }
      }
      

      三.示例代碼

      @RunWith(SpringJUnit4ClassRunner.class)
      @ContextConfiguration(locations = {"classpath:applicationContext.xml"})
      public class MapperTest {
          @Autowired
          private DepartmentMapper departmentMapper;
      
          @Test
          public void testCRUD(){
              System.out.println(departmentMapper);
          }
      }
      

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多