- 加入@WebAppConfiguration注解,表明这是一个WEB应用配置;
- 如果第1步解决不了,尝试加入Tomcat库到类路径,我的就解决了;
- 完成代码如下:
/**
* mail: love1208tt@foxmail.com
* Copyright (c) 2018. missbe
* @Date:18-9-21 下午7:58
* @author lyg
**/
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = "classpath:mybatis.xml")
public class SoftwareMapperTest {
@Autowired
private SoftwareMapper softwareMapper;
@Test
public void listPageSoftware() {
List<SoftwareEntity> res = softwareMapper.listPageSoftware(0, "", "", "soft_id", "desc", 0, 10);
for (SoftwareEntity entity : res){
System.out.println(entity);
}
}
}