简体   繁体   English

在类路径中无法从jar找到applicationContext.xml

[英]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.

相关问题 来自另一个jar的applicationcontext.xml春季服务 - applicationcontext.xml spring servrices from another jar 如何将 applicationContext.xml 和 Bean 从外部 jar 导入@SpringBootTest? - How to import applicationContext.xml and Bean from external jar to @SpringBootTest? Eclipse RCP找不到applicationContext.xml - Eclipse RCP cannot find applicationContext.xml 从applicationcontext.xml获取空值 - Getting null value from applicationcontext.xml 从applicationContext.xml读取环境变量 - Read an environment variable from applicationContext.xml 在 SpringBoot 项目中调用外部 jar 是否需要 ApplicationContext.xml - Is ApplicationContext.xml necessary in a SpringBoot project to call an external jar 使用java类加载jar中存在的Applicationcontext.xml - use java class to load Applicationcontext.xml present inside jar 为什么Spring-servlet.xml上的Beans无法访问applicationContext.xml中的bean - Why Beans on spring-servlet.xml can't access beans in my applicationContext.xml 如何使用SL4J在单独的文件中记录applicationContext.xml中定义的bean的异常 - How can use SL4J to log Exceptions from beans defined in applicationContext.xml in a separate file applicationContext.xml调用CronTriggerScheduler,但未计划应用程序 - applicationContext.xml calls the CronTriggerScheduler but application isn't scheduled
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM