错误信息:
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
本博客文章绝大多数为原创,少量为转载,代码经过测试验证,如果有疑问直接留言或者私信我。
创作文章不容易,转载文章必须注明文章出处;如果这篇文章对您有帮助,点击右侧打赏,支持一下吧。
创作文章不容易,转载文章必须注明文章出处;如果这篇文章对您有帮助,点击右侧打赏,支持一下吧。