加载我的应用程序 spring 上下文时,出现以下错误(仅在 Linux 计算机上,在 Windows 上似乎可以正常工作):
Failed to read schema document 'http://www.springframework.org/schema/tool/spring-tool-4.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not xsd:schema.
堆栈跟踪如下:
org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/score/context/scoreRepositoryContext.xml]
2015-03-30 11:07:49:336 127901 [main] WARN org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Ignored XML validation warning
org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/tx/spring-tx.xsd; lineNumber: 12; columnNumber: 150; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tool/spring-tool-4.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not xsd:schema.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:99)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:433)
at
...
at org.springframework.shell.Bootstrap.main(Bootstrap.java:58)
Caused by: java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
知道为什么吗?
最佳答案
问题几乎可以肯定是 Spring 库版本问题。
Update your Spring libraries on the Linux machine :
Make sure that there aren't any conflicting jars (different spring versions) on the classpath. If you use spring 3.0 there should be no big fat spring.jar (which is spring 2.5 and before). Next if you are creating a uber jar which contains all packages als make sure you copy xsd files also.
[信用:Marten Deinum (如上所述),Tristan 和 Michael Lee 通过删除网络连接检查建议改进了这个答案。]
关于java - 无法读取架构文档 'http://www.springframework.org/schema/tool/spring-tool-4.1.xsd',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29471695/