标签:sch style sock tco cut adp iss col handler
错误信息:
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String at org.springframework.data.redis.serializer.StringRedisSerializer.serialize(StringRedisSerializer.java:35) at org.springframework.data.redis.core.AbstractOperations.rawHashValue(AbstractOperations.java:184) at org.springframework.data.redis.core.DefaultHashOperations.put(DefaultHashOperations.java:175) at com.xxx.service.impl.CacheServiceImpl.setCacheMap(CacheServiceImpl.java:670) at com.xxx.service.impl.CacheServiceImpl.setCacheMap(CacheServiceImpl.java:683) at com.xxx.ws.StatusSocketClient.onMessage(StatusSocketClient.java:104) at sun.reflect.GeneratedMethodAccessor410.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45005) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.websocket.pojo.PojoMessageHandlerWholeBase.onMessage(PojoMessageHandlerWholeBase.java:80) at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:394) at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:495) at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:294) at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:133) at org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:95) at org.apache.tomcat.websocket.WsFrameClient.resumeProcessing(WsFrameClient.java:209) at org.apache.tomcat.websocket.WsFrameClient.access$300(WsFrameClient.java:31) at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.doResumeProcessing(WsFrameClient.java:186) at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:163) at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:148) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) at sun.nio.ch.Invoker$2.run(Invoker.java:218) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
找到redis相关配置:发现hash的键值序列化设置如下
/*hash字符串序列化方法*/ template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer());
修改后如下
template.setHashValueSerializer(new JdkSerializationRedisSerializer());
参考来源:https://blog.csdn.net/qq_26525215/article/details/69367588
springboot项目中使用spring-data-Redis对map序列化时报错
标签:sch style sock tco cut adp iss col handler
原文地址:https://www.cnblogs.com/passedbylove/p/11994533.html