这里讨论两种情况:
第一种:如果Spring的配置文件在类路径下:
单元测试:@ContextConfiguration(locations={"classpath:applicationContext.xml"})
启动配置:classpath:applicationContext.xml
在类路径下比较好理解;
第二种在WEB-INF目录下:
这时候需要分是否为Maven项目来讨论:
如果为一般的JavaEE项目:
单元测试:@ContextConfiguration(locations={"file:WebContent/WEB-INF/applicationContext.xml"})
启动配置:/WEB-INF/applicationContext.xml
如果为Maven项目:
单元测试:@ContextConfiguration(@ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/applicationContext.xml"}) )
启动配置:/WEB-INF/applicationContext.xml