Spring Junit reads the configuration file under WEB-INF

Test environment: Spring3.0.5 + Junit4.8.1

configuration files are placed in the class directory:
[java] view plain copy
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml"); 
Under WEB-INF:

[java] view plain copy
ApplicationContext applicationContext = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/spring.xml"); 

Multiple files are available *represents
[java] view plain copy
ApplicationContext applicationContext = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/spring-*.xml"); 

Annotation method:

class:
[java] view plain copy
@ContextConfiguration(locations={"classpath:spring.xml"}) 
WEB-INF:
[java] view plain copy
@ContextConfiguration(locations={"file:WebRoot/WEB-INF/spring.xml"}) 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326337911&siteId=291194637