Configuration problem: Failed to import bean definitions from relative location


問題現象:

 最近開始做新需求,然后在Tomcat上部署項目時,出現了如下報錯:

 [12-05 09:54:27,161 ERROR] ContextLoader.java:351 - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [spring-controller-slave.xml]
Offending resource: class path resource [spring.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from URL [file:/E:/java/tomcat/apache-tomcat-8.5.31/webapps/ROOT/WEB-INF/classes/spring-controller-slave.xml]; nested exception is java.io.FileNotFoundException: E:\java\tomcat\apache-tomcat-8.5.31\webapps\ROOT\WEB-INF\classes\spring-controller-slave.xml 

具體就是IO解析錯誤,無法解析XML文件,

 IOException parsing XML document from class path resource [file:/E:/java/tomcat/apache-tomcat-8.5.31/webapps/ROOT/WEB-INF/classes/spring-controller-slave.xml]

 

問題分析:

這個問題是概率性出現的,文件是存在的,但是還是報錯了,懷疑是Tomcat緩存問題。

於是清除了Tomcat緩存,clean了項目,甚至update了maven項目,然后再啟動tomcat,有概率性成功;如果還是失敗,就在Tomcat發布項目的地方,將發布項目的文件夾刪除,然后重新clean,一般來說,就會成功了。

這個問題雖然這樣可以解決,但具體的原理還是不清楚,待以后慢慢研究,先記下再說。

最終發現是編譯后的target文件夾里面里面缺少xml文件導致的,

最簡單的就是手動copy缺少的xml文件進去重啟tomcat解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM