[英]Can't find applicationContext.xml from jar in classpath
我有Spring的Maven項目。 我在classpath中有一個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" />
如果我理解正確,那么您希望前端訪問后端項目的applicationContext.xml。 然后,classpath *是正確的語句,您應確保兩個配置文件的名稱空間都相同。
例如,這種情況將不起作用
前端:
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
后端:
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.