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);
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-11-23
  • 2021-06-08
  • 2021-10-07
  • 2021-10-20
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-06-24
  • 2021-07-10
相关资源
相似解决方案