[英]Can't find applicationContext.xml from jar in classpath
I have Maven project with Spring. 我有Spring的Maven项目。 I have backend project as jar in the classpath(added as maven dependency).
我在classpath中有一个jar项目(添加为maven依赖项)。 The backend project is with Spring again and has it's own applicationContext.xml.
后端项目再次与Spring一起使用,并且拥有自己的applicationContext.xml。 In the frontend project I have applicationContext.xml and I want to access the application context from tha backend like this:
在前端项目中,我有applicationContext.xml,我想从后端访问应用程序上下文,如下所示:
<import resource="classpath:applicationContext.xml" />
but i got: 但我得到了:
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
Also tried: 还尝试了:
<import resource="classpath*:applicationContext.xml" />
and 和
<import resource="classpath:/applicationContext.xml" />
If I understand correctly, you want the front end to access the applicationContext.xml of the back end project. 如果我理解正确,那么您希望前端访问后端项目的applicationContext.xml。 Then classpath* is the right statement, and you should make sure namespaces of both configuration files are the same.
然后,classpath *是正确的语句,您应确保两个配置文件的名称空间都相同。
For example, this case won't work 例如,这种情况将不起作用
Front end: 前端:
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
Back end: 后端:
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.