gpt4 book ai didi

java - 找不到元素的声明(XML 架构)

转载 作者:行者123 更新时间:2023-12-01 18:53:41 24 4
gpt4 key购买 nike

当我不在线时,我通常会遇到这种错误:

org.xml.sax.SAXParseException; lineNumber: 55; columnNumber: 33; schema_reference.4: Failed to read schema document 'http://www.hazelcast.com/schema/spring/hazelcast-spring-2.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>.

Caused by: java.net.ConnectException: Connection timed out: connect

...no declaration can be found for element 'hz:hazelcast'.

有什么解决方案可以使它不必每次都连接到互联网。

最佳答案

您没有在问题中确切说明如何加载需要此架构的 XML 文件,但从其名称​​来看,它似乎与 Spring bean 配置有关。 Spring 有一种组件机制,可以提供自己的模式,将这些模式捆绑在 JAR 文件中,这样就不必从互联网上获取它们。这涉及 JAR 文件中名为 META-INF/spring.schemasjava.util.Properties 格式文件,其中包含将 http URL 映射到本地路径的行(在JAR 文件),例如

http\://www.hazelcast.com/schema/spring/hazelcast-spring-2.1.xsd=hazelcast-spring-2.1.xsd

(来自 hazelcast-spring-2.1.3.jar)。

所以我怀疑这里发生的情况是您指的是与您实际使用的 hazelcast 版本不同的架构版本,这意味着您请求的架构未在 spring.schemas 中列出 目录,因此必须到互联网上下载。例如,如果您有hazelcast-spring-2.5.jar,那么您需要使用匹配的http://www.hazelcast.com/schema/spring/hazelcast-spring-2.5 xsi:schemaLocation 中的 .xsd

关于java - 找不到元素的声明(XML 架构),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14891282/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com