我有一个这样组织的项目:
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 中时,一切正常。
我注意到堆栈跟踪上的一些错误中删除了前导/
,我想知道这是否与它有关。
另外,我(不幸的是)使用 Spring 2.5,如果这很重要的话。