只需在测试类上加上这两个注解,即可在测试类中使用@Autowired注入对象。
注:配置文件路径根据自身情况更改
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:config/applicationContext.xml" })
只需在测试类上加上这两个注解,即可在测试类中使用@Autowired注入对象。
注:配置文件路径根据自身情况更改
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:config/applicationContext.xml" })