首页 新闻 会员 周边

Spring Junit@ContextConfiguration如何读取、加载 WEF-INFO下的配置文件?真的很急啊,在线等大神指点!

0
悬赏园豆:100 [待解决问题]

放在类路径下好写,但目前我的spring配置文件放在WEF-INFO目录下,搞了一晚上硬是搞不好,请大声指点迷津!
我的项目结构及配置文件的具体位置:

测试类otherTest及问题描述:

如果上面截图看不清,请看这里的描述:

@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
}
}

谢谢了,在线急等你的指点!

Tom1997的主页 Tom1997 | 初学一级 | 园豆:102
提问于:2015-09-17 06:49
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册