码迷,mamicode.com
首页 > 其他好文 > 详细

SSM+mybatis单元测试

时间:2018-10-15 14:54:24      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:rgb   art   orm   ati   autowire   info   dao层   service   back   

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

SSM+mybatis单元测试

标签:rgb   art   orm   ati   autowire   info   dao层   service   back   

原文地址:https://www.cnblogs.com/songhaozhi080616/p/9790045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!