私はこのように組織されたプロジェクトを持っています:
core
-- /src/main/resources/company/config/spring-config.xml
webapp
-- /WEB-INF/applicationContext.xml
webappはに依存します。これは、デプロイ時にcore.jar
正しく含まれています。WEB-INF/lib
私web.xml
が持っている:
<param-value>
/WEB-INF/applicationContext.xml
</param-value>
そしてapplicationContext.xml
私は持っています:
<import resource="classpath:/company/config/spring-config.xml" />
しかし、実行すると、次のエラーが発生します。
2012-10-04 20:03:39,156 [localhost-startStop-1] springframework.web.context.ContextLoader ERROR: Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/company/config/spring-config.xml]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [company/config/spring-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [company/config/spring-config.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
....
Caused by: java.io.FileNotFoundException: class path resource [company/config/spring-config.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
... 36 more
spring-config.xml
がwebappにある場合、すべてが正常に機能します。
スタックトレースのエラーの一部から先頭が削除されていることに気づきました/
。これはそれと関係があるのではないかと思います。
また、私は(残念ながら)Spring2.5を使用しています。