Configuration problem: Failed to import bean definitions from relative location
Posted syp172654682
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 omcatapache-tomcat-8.5.31webappsROOTWEB-INFclassesspring-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解决
以上是关于Configuration problem: Failed to import bean definitions from relative location的主要内容,如果未能解决你的问题,请参考以下文章
Launching New_configuration has encountered a problem
Configuration problem: Failed to import bean definitions from relative location
开源项目运行时报错A problem was found with the configuration of task ‘:app:checkDebugManifest‘
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace 解决方法
关于Configuration problem: Failed to import bean definitions from URL location [classpath:spring-jdbc.
Unable to start the daemon process . This problem might be caused by incorrect configuration of the