我正在尝试从数据库中获取数据并放入地图并尝试将该地图存储在hazelcast 缓存服务器中。但它给出了错误
com.hazelcast.nio.serialization.HazelcastSerializationException:无法序列化“java.util.TreeMap”。
下面是我的代码。
Map<Integer, List> cacheMap;
cacheMap = (Map<Integer, List>) hazelCastCache.getDataFromCache("CdnToIpConfig", key);
if(cacheMap == null)
{
LOGGER.info("Cache memory is not allocated");
cacheMap = newTreeMap<>();
cdnIpResDto = configurationService.getCdnIpConfig(pageNo,sortBy,sortingOrder);
responseDataRange = cdnIpResDto.getDtoList();
int lastIndexTracker =0;
for (int i = 1; i <= responseDataRange.size(); i++) {
if (i % 10 == 0) {
finalData = responseDataRange.subList(i - 10, i);
cacheMap.put(pageNo, finalData);
System.out.println(cacheMap);// I can see contents of cacheMap
pageNo++;
lastIndexTracker = i;
}
}
hazelCastCache.addDataToCache("CdnToIpConfig", key, cacheMap);
System.out.println("Data added in Hazelcast"); // This line is not getting executed.
由于最后一行打印语句没有被执行,这意味着 TreeMap 没有被添加到缓存中。请帮忙?