@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(SpringJUnit4ClassRunner.class)报错,导入包也报错,输入时就没有提示
但是@Test能正常运行,
正在回答 回答被采纳积分+1
package com.imooc.demo.demo4;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import javax.annotation.Resource;
@RunWith(SpringJunit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext2.xml ")
public class SpringDemo4 {
@Resource(name = "customerDao")
private CustomerDao customerDao;
@Test
public void demo1(){
customerDao.find();
customerDao.save();
customerDao.update();
customerDao.delete();
}
}
注释掉
@RunWith(SpringJunit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext2.xml ")
和对应的包还是报错,
package com.imooc.demo.demo4;
import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.test.context.ContextConfiguration;
import javax.annotation.Resource;
//@RunWith(SpringJunit4ClassRunner.class)
//@ContextConfiguration("classpath:applicationContext2.xml ")
public class SpringDemo4 {
@Resource(name = "customerDao")
private CustomerDao customerDao;
@Test
public void demo1(){
customerDao.find();
customerDao.save();
customerDao.update();
customerDao.delete();
}
}
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星