即使没有互联网连接,我想让我的应用程序连接。 我在使用Spring和application-context.xml文件;我有这样的定义:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http\://www.springframework.org/schema/beans =
org/springframework/context/config/spring-context.xsd
http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd =
org/springframework/context/config/spring-context-2.5.xsd ">
但是在schemalocation中编写类路径时,我遇到了错误:
java.lang.RuntimeException: Factory::getBean - java.lang.RuntimeException: Factory::createApplicationContext - org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from file [C:\Users\SaMali\Desktop\DSC\Solutions\Workday\DTL-DMT Codebase\DTL 1.6.1.5 code to be used\DTL 1.6.1.5\.\properties\hoover-spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 251; cvc-elt.1: Cannot find the declaration of element 'beans'.
at aggressor.util.Factory.getBean(Factory.java:201)
at aggressor.util.Factory.getBean(Factory.java:201)
at aggressor.util.Factory.getBean(Factory.java:174)
at aggressor.core.Server.main(Server.java:423)
Caused by: java.lang.RuntimeException: Factory::createApplicationContext - org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from file [C:\Users\SaMali\Desktop\DSC\Solutions\Workday\DTL-DMT Codebase\DTL 1.6.1.5 code to be used\DTL 1.6.1.5\.\properties\hoover-spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 251; cvc-elt.1: Cannot find the declaration of element 'beans'.
at aggressor.util.Factory.createApplicationContext(Factory.java:140)
at aggressor.util.Factory.getBean(Factory.java:190)
... 2 more
答案 0 :(得分:0)
尝试正确设置schemaLocation。
xsi:schemaLocation="http://www.springframework.org/schema/beans = http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util = http://www.springframework.org/schema/util/spring-util-2.5.xsd"
答案 1 :(得分:0)
与Java 1.8有同样的错误,所以我安装了jdk-7u80-windows-x64.exe并添加了以下变量
SET PATH=C:\Program Files\Java\jdk1.7.0_80\bin
SET CLASSPATH=C:\Program Files\Java\jdk1.7.0_80\lib
SET JAVA_HOME=C:\Program Files\Java\jdk1.7.0_80
它就像魅力一样。
答案 2 :(得分:0)
根据堆栈跟踪,
这说明xml在阅读时遇到了一些问题。因此,SAXParsingException。
您可以更改xsi:schemaLocation:http\://
到
xsi:schemaLocation:http://
并在需要时应用这些更改。这可以解决您的问题。