81,122
社区成员




@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:WebRoot/WEB-INF/applicationContext.xml" })
public class otherTest{
@Autowired
private Type t;
@Autowired
private HibernateTemplate hibernateTemplate;
//问题:applicationContext.xml放在WEB-INFO目录下,@ContextConfiguration根本无法加载applicationContext.xml。
@Test
public void daoOrServiceIsExist() {
System.out.println(hibernateTemplate);//fail
}
//说明:applicationContext2.xml放在类路径下,可以从中获取Bean实例。
@Test
public void successTest(){
System.out.println(t);//ok
System.out.println(hibernateTemplate);//ok
}
}
@ContextConfiguration(locations = { "classpath:spring/weipay-test.xml" })