SSM+mybatis单元测试
生活随笔
收集整理的這篇文章主要介紹了
SSM+mybatis单元测试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
初學SSM+mybatis單元測試遇到的問題,dao注入后為null
Dao層注入失敗,查看后,發現注解都寫的無誤,經朋友的指點,在測試類上加了一句“@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={“classpath:spring/applicationContext-tx.xml”,“classpath:spring/applicationContext-service.xml”,“classpath:spring/applicationContext-dao.xml”})” 經測試,Dao可以注入,不再為null --------------------- 作者:旅途上的背包客 來源:CSDN 原文:https://blog.csdn.net/u012799877/article/details/83056657?utm_source=copy 版權聲明:本文為博主原創文章,轉載請附上博文鏈接!
?
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:spring/applicationContext-tx.xml","classpath:spring/applicationContext-service.xml","classpath:spring/applicationContext-dao.xml"})
public class TaskInfoTest {
@Autowired
TaskService taskService;
@Test
public void test(){
TaskInfo taskInfo = new TaskInfo();
taskInfo.setTid(2);
taskInfo.setTname("taskname");
taskInfo.setStatus("成功");
taskInfo.setBtime("2018-10-12");
taskInfo.setEtime("2018-10-15");
taskService.add(taskInfo);
}
}
轉載于:https://www.cnblogs.com/songhaozhi080616/p/9790045.html
總結
以上是生活随笔為你收集整理的SSM+mybatis单元测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SqlServer性能优化 即席查询(十
- 下一篇: React-Router ---with