cvc-elt.1:找不到元素"榛子"的声明



我正在尝试使用Spring配置Hazelcast。 我正在使用单独的文件进行 Hazelcast 的 xml 文件配置,我检查了我在 XML 中配置的 xsd 在这个文件中它包含"hazelcast"元素,并且还根据 xsd 中的命名空间规范进行了配置,还添加了 3.3 版本的 hazelcast、hazelcast-all 和 hazelcast-spring。

我检查了 xsd 文件 - http://www.hazelcast.com/schema/config hazelcast-config-3.3.xsd ,我可以在其中打开并找到 hazelcast 元素。

你可以在这里引用 hazlecast xml - https://dzone.com/articles/configuring-hazelcast-within

<hazelcast  
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.3.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >      
<group>
<name>hazelcast</name>
<password>12345</password>
</group>
<properties>
<property name="hazelcast.logging.type">slf4j</property>
<property name="hazelcast.jmx">true</property>
<property name="hazelcast.jmx.detailed">true</property>
</properties>
<management-center enabled="false">http://localhost:8080/hazelcast</management-center>

<map name="HttpRequestsCache">
<time-to-live-seconds>600</time-to-live-seconds>
<max-size>1000</max-size>
</map>



</hazelcast>

但是得到一个错误——

在此行中找到多个注释: - 无法找到架构命名空间"http://www.hazelcast.com/"的元素"hazelcast"的 Spring 命名空间处理程序 架构/配置' - cvc-elt.1:找不到元素"hazelcast"的声明。 - schema_reference.4:无法读取架构文档"hazelcast-config-3.3.xsd",因为

1)找不到文件; 2)文件无法阅读; 3) 文档的根元素不是 。

您的 XML 在帖子上的格式不正确,但我怀疑问题是

xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.3.xsd"

应该是

xsi:schemaLocation="http://www.hazelcast.com/schema/config http://www.hazelcast.com/schema/config/hazelcast-config-3.3.xsd"

如果要将 Hazelcast 添加到项目中,最好选择比 3.3 更新的版本。当前为 3.12。

这里有大量的 Spring 工作示例作为基础,使用正确的 XML。

Eclipse 2020-06 也有同样的错误,使用"https"URL 为我修复了它:

<hazelcast xsi:schemaLocation="https://www.hazelcast.com/schema/config hazelcast-config-3.6.xsd"
xmlns="https://www.hazelcast.com/schema/config"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance">

最新更新