在从 3.12.13 版本迁移到 5.1.6 版本时遇到问题,如果有人知道如何解决此问题,请告诉我。
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.cp.ISemaphore;
public class HazelcastSemaphore implements MetaSemaphore {
private HazelcastInstance hazelcastInstance;
public boolean init(int permits) {
if(semaphore == null){
hz1.getCPSubsystem().getSemaphore(id);
semaphore.init(permits);
}
return true;
}
}
面临错误
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.services.config.ConfigService]: Factory method 'configService' threw exception; nested exception is com.hazelcast.core.HazelcastException: CP Subsystem is not enabled!
您必须启用 CP 子系统。
XML 示例
<hazelcast>
<cp-subsystem>
<!-- set cp-member-count with value 0 to run in unsafe mode -->
<cp-member-count>3</cp-member-count>
<!-- configuration options here -->
</cp-subsystem>
</hazelcast>
在这里阅读更多内容: https://docs.hazelcast.com/hazelcast/5.3/cp-subsystem/configuration