J2EE开发时applicationContext在WebContent/WEB-INF/中
@ContextConfiguration(locations={"classpath:applicationContext.xml"}) 此注解无法取到
两种解决办法
1、用文件注解的形式@ContextConfiguration(locations="file:WebContent/WEB-INF/applicationContext.xml")
2、在eclipse的.classpath 文件中加入<classpathentry kind="src" path="WebContent/WEB-INF">
@ContextConfiguration Spring整合JUnit4测试时,使用注解引入多个配置文件
单个文件
@ContextConfiguration(Locations="../applicationContext.xml")
@ContextConfiguration(classes = SimpleConfiguration.class)
多个文件时,可用{}
@ContextConfiguration(locations = { "classpath*:/spring1.xml", "classpath*:/spring2.xml" })