报错4_使用Redis缓存org.springframework.data.redis.serializer.SerializationException: Could not read JSON..
问题描述使用Redis缓存数据,能成功保存到Redis且使用的value的序列化格式为:GenericJackson2JsonRedisSerializer,但是第二次从缓存中获取报错关键报错信息,提示没有构造器org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Cannot
·
问题描述
使用Redis缓存数据,能成功保存到Redis
且使用的value的序列化格式为:GenericJackson2JsonRedisSerializer,但是第二次从缓存中获取报错
关键报错信息,提示没有构造器
org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Cannot construct instance of `io.renren.common.utils.PageUtils` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
问题解决
- 第一种方法,直接将value的序列化改为String类型
- 第二种方法,添加空参构造
采用第二种方式解决,第一种方式的缺点就是中文信息可能会被转义

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)