2017-05-25 41 views
0

使用hazelcast 3.8.2(hazelcast-all jar)+ IMap + mapstore + Spring 4.3.8(xml config)。在Spring xml配置中,'hz:map-store'会抛出一个错误:Hazelcast + Spring(xml config)+ hz map store error

17:49:40.519 ERROR [main] org.springframework.test.context.TestContextManager – Caught exception while allowing TestExecutionListener [org.springframewor[email protected]1868ed54] to prepare test instance [[email protected]3e3] org.xml.sax.SAXParseException: cvc-complex-type.2.1: Element 'hz:map' must have no character or element information item [children], because the type's content type is empty. 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[?:1.8.0_101] 

我在做什么错?

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:hz="http://www.hazelcast.com/schema/spring" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
       http://www.hazelcast.com/schema/spring 
       http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd"> 



    <hz:hazelcast id="hzInstance1"> 
     <hz:config> 
     ... 
     </hz:config> 
    </hz:hazelcast> 

    <hz:client id="hzInstance1Client"> 
    ... 
    </hz:client> 

    <hz:map id="entitlementCache" instance-ref="hzInstance1" name="entitlement"> 
     <hz:map-store enabled="true" implementation="linearEntitlementMapStore" 
        write-delay-seconds="30000"/> 

    </hz:map> 

    <bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore" /> 
</beans> 

回答

0

您需要在<hz:config>部分配置MapStore。

正确的配置应该是这样的

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:hz="http://www.hazelcast.com/schema/spring" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
      http://www.hazelcast.com/schema/spring 
      http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd"> 

<hz:hazelcast id="hzInstance1"> 
    <hz:config> 
     <hz:map name="entitlement"> 
      <hz:map-store enabled="true" implementation="linearEntitlementMapStore" 
          write-delay-seconds="30000"/> 
      <!-- ... --> 
     </hz:map> 
    </hz:config> 
</hz:hazelcast> 

<hz:client id="hzInstance1Client"> 
    <!--... --> 
</hz:client> 

<bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore"/>