Spring+Junit 读取WEB-INF上的配置文件

Spring+Junit 读取WEB-INF下的配置文件

测试环境:Spring3.0.5 + Junit4.8.1

 

配置文件放在class目录下:

ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");

 WEB-INF下:

ApplicationContext applicationContext = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/spring.xml");

 

注解方式:

class:

@ContextConfiguration(locations={"classpath:spring.xml"})

 WEB-INF:

@ContextConfiguration(locations={"file:WebRoot/WEB-INF/spring.xml"}) 
posted @ 2014-07-10 11:59  逝去的十月  阅读(237)  评论(0)    收藏  举报