zoukankan      html  css  js  c++  java
  • maven springTest结合junit单元测试

    1.引入相关依赖

    <dependency>
    	<groupId>junit</groupId>
    	<artifactId>junit</artifactId>
    	<version>3.8.1</version>
    	<scope>test</scope>
    </dependency>
    <dependency> 
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-test</artifactId>
    	<version>${spring.version}</version>
    	<scope>test</scope>
    </dependency>    
    

    2.新建java单元测试文件加上spring配置文件的注解 

    @RunWith(SpringJUnit4ClassRunner.class)  
    @ContextConfiguration({"classpath*:spring/*.xml"})
    public class MapperTest {
    
        @Autowired
        private ProductTypeMapper mapper;
        
        @Test
        public void testProductType(){
            ProductTypeExample example = new ProductTypeExample();
            List<ProductType> list = mapper.selectByExample(example);
            System.out.println(list);
        }
    }
  • 相关阅读:
    PS封装ES流
    win7无法删除文件夹,提示“找不到该项目”
    声明
    ZR#1005
    ZR#1004
    ZR#1009
    ZR#1008
    ZR#1015
    ZR#1012
    ZR#985
  • 原文地址:https://www.cnblogs.com/czsblog/p/10416756.html
Copyright © 2011-2022 走看看