1.添加单元测试的maven依赖
2.创建测试类
3.测试类添加注解
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:applicationContext_dao.xml","classpath:applicationContext_service.xml"})
classpath:后面的内容是你自己spring的配置文件
4.在测试类中添加测试方法
@Autowired
ProductInfoMapper productInfoMapper;//mapper的dao接口
@Test
public void m1(){
ProductInfoVo vo=new ProductInfoVo();
vo.setLprice(1000);
//vo.setHprice(2000);
List<ProductInfo> list=productInfoMapper.selectCondition(vo);
for (ProductInfo productInfo : list) {
System.out.println(productInfo);
}
}
输出结果
5.在mybatis配置文件中添加日志信息
<settings> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings>
输出结果