我有 Spring 的 Maven 项目。我在类路径中有后端项目作为 jar(添加为 maven 依赖项)。后端项目再次使用 Spring 并拥有自己的 applicationContext.xml。在前端项目中,我有 applicationContext.xml,我想从后端访问应用程序上下文,如下所示:
<import resource="classpath:applicationContext.xml" />
但我得到了:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:applicationContext.xml]
Offending resource: ServletContext resource [/WEB-INF/appContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
也试过:
<import resource="classpath*:applicationContext.xml" />
和
<import resource="classpath:/applicationContext.xml" />