如何避免在春季初始化期间从互联网下载架构文件 [英] How to avoid downloading schema file from internet during spring initialization

查看:26
本文介绍了如何避免在春季初始化期间从互联网下载架构文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在不允许公共互联网访问的生产服务器上运行的网络应用程序.初始化失败,错误如

I have a web app running on a production server which does not allow public internet access. The initialization fails with error like

2010-02-18 15:21:33,150 **WARN**  [SimpleSaxErrorHandler.java:47] Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'https://jax-ws.dev.java.net/spring/servlet.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:195)
 ...

2010-02-18 15:21:33,154 **ERROR** [ContextLoader.java:215] Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from ServletContext resource [/WEB-INF/app.xml] is invalid; nested exception is org.xml.sax.SAXPar
seException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:389)

似乎第一个 WARN 表示应用程序无法下载架构文件,这导致了第二个错误.

It seems the 1st WARN indicates the app failed to download the schema file, which caused the 2nd ERROR.

我的问题是:

  1. 我觉得我应该能够运行一个应用程序而无需访问互联网是合理的.我如何要求 xml 解析器使用本地架构文件而不是从 Internet 下载的副本.我知道 XML 目录有能力.我正在使用 tomcat 和 spring.有没有办法配置XML目录?是否有其他机制可以达到同样的目的?

  1. I feel it is reasonable that I should be able to run an app w/o having to have internet access. how can I ask the xml parser to use a local schema file instead of a copy downloaded from the internet. I know XML catalog has the capability. I am using tomcat and spring. Is there a way to configure XML catalog? Are there other mechanisms that can achieve the same purpose?

如果我无法重定向解析器以使用本地架构文件.我可以禁用 xml 架构验证吗?同样,我想只配置行为而不触及代码.

If I cannot redirect the parser to use a local schema file. Can I disable the xml schema validation? Again, I would like to just configure the behavior without touching the code.

推荐答案

把你需要的模式放在你的类路径中,然后使用 resolver 来使用它.

Put the schemas you need in your classpath, and then use a resolver to use it.

这篇关于如何避免在春季初始化期间从互联网下载架构文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆