在Spring中定义Hazelcast配置:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:hz="http://www.hazelcast.com/schema/spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.hazelcast.com/schema/spring http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd"> <context:annotation-config /> <hz:hazelcast id="instance"> <hz:config> <hz:network port="5701" port-auto-increment="true"> <hz:join> <hz:multicast enabled="true" multicast-group="224.2.2.3" multicast-port="54327" multicast-time-to-live="32" multicast-timeout-seconds="2" /> </hz:join> </hz:network> <hz:group name="pushcoregroup" password="password" /> </hz:config> </hz:hazelcast> </beans>
启动时,程序报错:
Caused by: org.xml.sax.SAXParseException; lineNumber: 25; columnNumber: 57; cvc-complex-type.2.4.a: 发现了以元素 'hz:group' 开头的无效内容。应以 '{"http://www.hazelcast.com/schema/spring":partition-group, "http://www.hazelcast.com/schema/spring":executor-service, "http://www.hazelcast.com/schema/spring":queue, "http://www.hazelcast.com/schema/spring":map, "http://www.hazelcast.com/schema/spring":cache, "http://www.hazelcast.com/schema/spring":multimap, "http://www.hazelcast.com/schema/spring":list, "http://www.hazelcast.com/schema/spring":set, "http://www.hazelcast.com/schema/spring":topic, "http://www.hazelcast.com/schema/spring":jobtracker, "http://www.hazelcast.com/schema/spring":replicatedmap, "http://www.hazelcast.com/schema/spring":listeners, "http://www.hazelcast.com/schema/spring":serialization, "http://www.hazelcast.com/schema/spring":security, "http://www.hazelcast.com/schema/spring":member-attributes, "http://www.hazelcast.com/schema/spring":services}' 之一开头。 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:458) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3237) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1796) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:766) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:356) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347) at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391) ... 14 more
通过排查后,发现http://hazelcast.com/schema/spring/hazelcast-spring-3.4.xsd中定义了元素出现的顺序,
<xs:element name="config"> <xs:complexType> <xs:complexContent> <xs:extension base="hazelcast-bean"> <xs:sequence> <xs:element name="spring-aware" type="spring-aware" minOccurs="0" maxOccurs="1"/> <xs:element name="instance-name" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="group" type="group" minOccurs="0" maxOccurs="1"/> <xs:element name="license-key" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="management-center" type="management-center" minOccurs="0" maxOccurs="1"/> <xs:element name="properties" type="properties" minOccurs="0" maxOccurs="1"/> <xs:element name="wan-replication" type="wan-replication" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="network" type="network" minOccurs="0" maxOccurs="1"/> <xs:element name="partition-group" type="partition-group" minOccurs="0" maxOccurs="1"/> <xs:element name="executor-service" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="queue" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="map" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="cache" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="multimap" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="list" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="set" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="topic" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="jobtracker" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="replicatedmap" minOccurs="0" maxOccurs="unbounded">...</xs:element> <xs:element name="listeners" type="listeners" minOccurs="0" maxOccurs="1"/> <xs:element name="serialization" type="serialization" minOccurs="0" maxOccurs="1"/> <xs:element name="security" type="security" minOccurs="0" maxOccurs="1"/> <xs:element name="member-attributes" minOccurs="0" maxOccurs="1">...</xs:element> <xs:element name="services" type="services" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:element name="data-serializable-factories">
其中xs:sequence指示器规定了各个元素出现的顺序,要求group出现在network的前面,于是,把配置改成这样:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:hz="http://www.hazelcast.com/schema/spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.hazelcast.com/schema/spring http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd"> <context:annotation-config /> <hz:hazelcast id="instance"> <hz:config> <hz:group name="pushcoregroup" password="password" /> <hz:network port="5701" port-auto-increment="true"> <hz:join> <hz:multicast enabled="true" multicast-group="224.2.2.3" multicast-port="54327" multicast-time-to-live="32" multicast-timeout-seconds="2" /> </hz:join> </hz:network> </hz:config> </hz:hazelcast> </beans>
问题就解决了!!
相关推荐
主要介绍了Spring Boot和Hazelcast使用详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
dropwizard-redirect-bundle.zip,一个简单的dropwizard包,允许http重定向。
在Spring Session 1.0.2中使用Hazelcast 3.5.1的示例 从Spring Session 1.1开始,此示例现在是Spring Session项目本身的一部分。 参见 。 安全榛树广播 以Hazelcast为后端而不是Redis的示例。 支持在到期时发送...
hazelcast示例Hazelcast,Spring Boot,域驱动设计
赠送jar包:hazelcast-3.7.2.jar; 赠送原API文档:hazelcast-3.7.2-javadoc.jar; 赠送源代码:hazelcast-3.7.2-sources.jar; 赠送Maven依赖信息文件:hazelcast-3.7.2.pom; 包含翻译后的API文档:hazelcast-...
赠送jar包:hazelcast-3.7.2.jar; 赠送原API文档:hazelcast-3.7.2-javadoc.jar; 赠送源代码:hazelcast-3.7.2-sources.jar; 赠送Maven依赖信息文件:hazelcast-3.7.2.pom; 包含翻译后的API文档:hazelcast-...
openfire使用hazelCast集群
[Packt Publishing] Hazelcast 入门教程 (英文版) [Packt Publishing] Getting Started with Hazelcast (E-Book) ☆ 图书概要:☆ An easy-to-follow and hands-on introduction to the highly scalable data ...
YARN-Hazelcast集成 这是对Apache YARN分布式外壳程序源代码的修改,以简化Hazelcast群集设置过程并利用惊人的YARN资源协商功能。 所需的只是Hazelcast zip文件(在进行必要的配置修改之后)。 它在提供的数量的群集...
hazelcast-4.1.1.zip包
赠送jar包:shiro-hazelcast-1.4.0.jar; 赠送原API文档:shiro-hazelcast-1.4.0-javadoc.jar; 赠送源代码:shiro-hazelcast-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-hazelcast-1.4.0.pom; 包含翻译后...
Hazelcast is a clustering and highly scalable data distribution platform for Java. Hazelcast helps architects and developers to easily design and develop faster, highly scalable and reliable ...
hazelcast-kubernetes, 用于Hazelcast的Google Kubernetes发现机制 用于Kubernetes目录的 Hazelcast发现插件Hazelcast发现 SPI配置属性文档配置文件REST API 请求DNS查找插件Docker 图像这个 Hazelcast插件发现插件...
hazelcast客户端代码,3.11.1版本。
Hazelcast 文档 version 3 2
integration with Spring and Hibernate and more importantly with so many happy users, Hazelcast is feature-rich, enterprise-ready and developer-friendly in-memory data grid solution. Features: ...
download from hazelcast.org. version 3.8.9. hazelcast-3.8.9.zip
从官网下载的Hazelcast原版配置说明文档;
hazelcast-3.9 。。hazelcast-3.9。。hazelcast-3.9有需要的下载。