我在将Spring与Hazelcast集成时遇到此错误。 请参阅spring-servelt.xml中的hazelcast配置。 我自动连接Hazelcast时出错。 请帮忙。
<hz:hazelcast id="srmsCacheInstance">
<hz:config>
<hz:instance-name>trunk</hz:instance-name>
<hz:group name="trunk" password="trunk" />
<hz:management-center enabled="false" url="http://127.0.0.1:8080/mancenter-3.2.1" />
<hz:properties>
<hz:property name="hazelcast.logging.type">log4j</hz:property>
</hz:properties>
<hz:network port="5701" port-auto-increment="true">
<hz:join>
<hz:multicast enabled="true" multicast-group="224.2.2.3" multicast-port="54333" />
</hz:join>
</hz:network>
<hz:map name="srmsCache" read-backup-data="false">
<hz:near-cache in-memory-format="OBJECT" cache-local-entries="true" />
</hz:map>
<hz:map name="cache.graph.tx" eviction-policy="LRU" eviction-percentage="30" read-backup-data="true" />
<hz:map name="cache.graph.no.tx" eviction-policy="LRU" eviction-percentage="30" read-backup-data="true" />
</hz:config>
</hz:hazelcast>
@DefaultCustomService("defaultCachingService")
public class DefaultCachingService {
private HazelcastInstance hazelcast;
@Autowired
public void setHazelcast(HazelcastInstance hazelcast) {
// Hazelcast.shutdownAll();
this.hazelcast = hazelcast;
}
protected HazelcastInstance hazelcast() {
return hazelcast;
}
public Object getCachedValue(String mapKey, String cacheKey) throws Exception {
return hazelcast().getMap(mapKey).get(cacheKey);
}
public Object deleteCachedValue(String mapKey, String cacheKey) throws Exception {
return hazelcast().getMap(mapKey).remove(cacheKey);
}
}
通过工厂方法进行Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[com.hazelcast.core.HazelcastInstance]:工厂方法&#39; newHazelcastInstance&#39;抛出异常;嵌套异常是com.hazelcast.core.DuplicateInstanceNameException:HazelcastInstance,名称为&#39; trunk&#39;已经存在! 在
此致 mmanish