在单元测试时发现无法注入,注入的对象都是null,原因是加载的时候没有把配置文件加载进来。在单元测试类上写上
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext.xml" })
这两个注解就可以了。
在单元测试时发现无法注入,注入的对象都是null,原因是加载的时候没有把配置文件加载进来。在单元测试类上写上
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext.xml" })
这两个注解就可以了。