我想在spring boot app上禁用hazelcast rest api。 我使用curl来发送数据,例如;
curl -v -X POST -H "Content-Type: text/plain" -d "bar" http://192....:5705/hazelcast/rest/maps/mapName/Example
返回是接受。我不想接受所以我需要禁用hazelcast rest api。 我试过了;
Config hazelConfig = new Config();
hazelConfig.setProperty("hazelcast.rest.enabled","false");
和
System.setProperty("hazelcast.rest.enabled", String.valueOf(false))
但没有工作。
applicationContext-hazelcast.xml:
<beans...
<hz:hazelcast id="hazelcastInstance">
<hz:config>
<hz:group name="..." password="...."/>
<hz:network port="5705" port-auto-increment="true">
<hz:join>
<hz:multicast enabled="false"
multicast-group="..."
multicast-port="..."/>
<hz:tcp-ip enabled="true">
<hz:members></hz:members>
</hz:tcp-ip>
</hz:join>
</hz:network>
<hz:map name="rights"
backup-count="2"
max-size="0"
eviction-percentage="30"
read-backup-data="true"
eviction-policy="NONE"
merge-policy="com.hazelcast.map.merge.PassThroughMergePolicy"/>
<hz:map name="users"
backup-count="2"
max-size="0"
eviction-percentage="30"
read-backup-data="true"
eviction-policy="NONE"
merge-policy="com.hazelcast.map.merge.PassThroughMergePolicy"/>
</hz:config>
</hz:hazelcast>
</beans>
和hazelcast属性;
@Bean(name = "hazelcastInstance")
public HazelcastInstance hazelcastInstance() {
Config hazelConfig = new Config();
// group config
hazelConfig.getGroupConfig().setName(...);
hazelConfig.getGroupConfig().setPassword(...);
//rest config again
hazelConfig.setProperty("hazelcast.rest.enabled","false");
hazelConfig.setProperty("hazelcast.health.monitoring.level", "OFF");
//rest config again
System.setProperty("hazelcast.rest.enabled", String.valueOf(false));
// management center config
hazelConfig.getManagementCenterConfig().setEnabled(true)
.setUrl(...)
.setUpdateInterval(...);// in seconds
//network config
hazelConfig.getNetworkConfig().setPort(...);
hazelConfig.getNetworkConfig().setPortAutoIncrement(true);
hazelConfig.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
hazelConfig.getNetworkConfig().getJoin().getMulticastConfig().setMulticastGroup(...);
hazelConfig.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(...);
hazelConfig.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(...);
// Defining maps to be used in cache
MapConfig mapConfigRights = new MapConfig();
mapConfigRights.setName(..);
mapConfigRights.setInMemoryFormat(...);
//Near cache is highly recommended for the maps that are read-mostly
mapConfigRights.setNearCacheConfig(...);
mapConfigRights.setReadBackupData(true);
mapConfigRights.setEvictionPolicy(...);
mapConfigRights.setMergePolicy(...);
hazelConfig.getMapConfigs().put(..., mapConfigRights);
return HazelcastInstanceFactory.newHazelcastInstance(hazelConfig);
}
我使用3.5.3到3.8.4的hazelcast版本,但仍接受rest api。
谢谢。