Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何脱机运行Spring应用程序?_Java_Spring - Fatal编程技术网

Java 如何脱机运行Spring应用程序?

Java 如何脱机运行Spring应用程序?,java,spring,Java,Spring,我有一个Spring应用程序(不是web应用程序),应该可以脱机运行。但是,当我尝试这样做时,它会崩溃,并显示以下错误消息: - Loading XML bean definitions from class path resource [applicationContext.xml] 21220 [main] WARN org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Ignored XML validatio

我有一个Spring应用程序(不是web应用程序),应该可以脱机运行。但是,当我尝试这样做时,它会崩溃,并显示以下错误消息:

- Loading XML bean definitions from class path resource [applicationContext.xml]
21220 [main] WARN  org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
 - Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tool/spring-tool-3.0.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(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(Unknown Source)
...
-从类路径资源[applicationContext.XML]加载XML bean定义
21220[main]WARN org.springframework.beans.factory.xml.XmlBeanDefinitionReader
-忽略XML验证警告
org.xml.sax.SAXParseException:schema_reference.4:无法读取架构文档'http://www.springframework.org/schema/tool/spring-tool-3.0.xsd,因为1)找不到该文档;2) 文件无法读取;3) 文档的根元素不是。
位于com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(未知源)
位于com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(未知源)
...

这是因为Spring无法找到模式,因为它们处于联机状态,而Spring处于脱机状态。如何脱机运行Spring应用程序?

Spring JAR包含
META-INF/Spring.handlers
META-INF/Spring.schemas
文件。为了避免在将依赖项聚合到一个jar时覆盖文件,您可以使用。

这里是我所做的。 我手动编辑了jar文件。 首先提取META-INF/spring.schemas文件。 添加了spring试图从internet下载的方案。 在我的例子中,是spring-beans.xsd和spring-tool.xsd。 像这样:

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans.xsd

以及我下载并添加到项目根目录中的另一个spring-tool.xsd模式。然后还将这一行添加到spring.schemas,如下所示:

http://www.springframework.org/schema/tool/spring-tool.xsd=spring-tool.xsd 一个缺点是每次重建项目时都必须编辑jar文件

在互联网上,人们说你必须给项目添加相应的依赖项。比如春豆。但这对我没有帮助。

重复。见:-等。