java.lang.IllegalStateException: Failed to load ApplicationContext

时间:2024-03-30 10:29:59

本文全部解决方案https://www.cnblogs.com/xjknight/p/10891130.html

java.lang.IllegalStateException: Failed to load ApplicationContext

首先排查,是否添加了这两个文件
java.lang.IllegalStateException: Failed to load ApplicationContext

java.lang.IllegalStateException: @Resource annotation requires a single-arg method

java.lang.IllegalStateException: Failed to load ApplicationContext

cvc-elt.1: Cannot find the declaration of element ‘beans’.

java.lang.IllegalStateException: Failed to load ApplicationContext

原因是无法从网络上读取到相应的schema文件,但实际上在浏览器中是可以访问的。

可以改成

xsi:schemaLocation="
http://www.springframework.org/schema/beans
classpath:/org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

从本地JAR包获取即可,无需从网上读取

java.lang.IllegalStateException: Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext

org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 68; schema_reference.4: 无法读取方案文档 ‘classpath:/org/springframework/spring-beans/5.0.2.RELEASE/spring-beans-5.0.2.RELEASE.jar’, 原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 xsd:schema。

Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]

同样解决方法

https://www.cnblogs.com/xjknight/p/10891130.html