如何离线运行我的Spring应用程序?

时间:2010-10-22 14:57:00

标签: 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 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)
...

这是由Spring无法找到模式引起的,因为它们在线并且Spring处于脱机状态。如何离线运行我的Spring应用程序?

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

这就是我的所作所为。 我手动编辑了jar文件。 首先提取META-INF / spring.schemas文件。 添加了春天试图从互联网上下载的方案。 在我的例子中,它是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文件。

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

相关问题