2017-04-06 76 views
1

我想在我的spring JUnit測試中啓動一個hazelcast實例。下面是XML配置我試圖加載作爲@ContextConfigurationbean class [com.hazelcast.config.Config]的屬性'semaphoreConfigs':

<?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: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-3.0.xsd 
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.0.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:spring-aware /> 
<hz:group name="dev" password="password"/> 
<hz:network port="5701" port-auto-increment="false"> 
    <hz:join> 
     <hz:multicast enabled="false" /> 
     <hz:tcp-ip enabled="true"> 
      <hz:members>127.0.0.1</hz:members> 
     </hz:tcp-ip> 
    </hz:join> 
</hz:network> 
</hz:config> 
</hz:hazelcast> 

正在此下方例外,任何指針是有益的

org.springframework.beans.NotWritablePropertyException:無效的屬性Bean類的[semaphoreConfigs] [com.hazelcast.config.Config]:Bean屬性'semaphoreConfigs'不可寫或具有無效的setter方法。 setter的參數類型是否與getter的返回類型相匹配? 在org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1042) 在org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:902) 在org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor。的java:75) 在org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)

+0

什麼Hazelcast版本?什麼春天的版本? Spring Boot還是簡單的Spring框架? – noctarius

+0

這是普通的Spring框架,Java版本是JDK 1.7。 Hazelcast是3.8和Spring版本是3.2.4.RELEASE。我實際上正在修改一箇舊的項目,並嘗試寫一些測試來實現它的工作。 –

回答

1

異常描述表明彈簧3.2.4.RELEASE不能由於吸氣劑返回之間的差異處理旗語CONFIGS類型和setter參數類型。從com.hazelcast.config.Config類:

public Collection<SemaphoreConfig> getSemaphoreConfigs() {...} 

public Config setSemaphoreConfigs(Map<String, SemaphoreConfig> semaphoreConfigs) {...} 

hazelcast-spring建&對Spring framework 4.3.0.RELEASE測試,它處理的信號配置創建正確(tested here)。如果升級Spring框架版本是一個選項,我會建議這樣做。