栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

redis.serializer.SerializationException: Could not read JSON: Unexpected character

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

redis.serializer.SerializationException: Could not read JSON: Unexpected character

使用@Cacheable注解引发的redis序列化报错 redis.serializer.SerializationException: Could not read JSON: Unexpected character
  • 错误解决办法
  • 报错信息如下

redis.serializer.SerializationException: Could not read JSON: Unexpected character)

错误解决办法

@Cacheable注解来自如下两个包:
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
当在需要对外输出的接口中使用了该redis缓存注解时,redis数据要先序列化,再通过网络传输出去,由于出现了缓存序列化错误,导致该缓存无法正常序列化传输出去。

解决办法就是不要用这个@Cacheable注解,使用其他方式使用redis缓存。

报错信息如下
org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Unexpected character ('¬' (code 172)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

 at [Source: (byte[])"�� sr java.util.ArrayListx����a� I sizexp   w   sr 6com.xhwl.common.pojo.cent.device.DeviceProductCategory        L codet Ljava/lang/String;L  createdAtt Ljava/util/Date;L idt Ljava/lang/Integer;L nameq ~ L  updatedAtq ~ xr 5com.baomidou.mybatisplus.extension.activerecord.Model         xppsr java.util.Datehj�KYt  xp  xF� xsr java.lang.Integer⠤���8 I valuexr java.lang.Number������  xp   t 系统sq ~  xF� xsq ~ psq ~  xF� xsq ~ 

   t "[truncated 297 bytes]; line: 1, column: 2]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('¬' (code 172)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

 at [Source: (byte[])"�� sr java.util.ArrayListx����a� I sizexp   w   sr 6com.xhwl.common.pojo.cent.device.DeviceProductCategory        L codet Ljava/lang/String;L  createdAtt Ljava/util/Date;L idt Ljava/lang/Integer;L nameq ~ L  updatedAtq ~ xr 5com.baomidou.mybatisplus.extension.activerecord.Model         xppsr java.util.Datehj�KYt  xp  xF� xsr java.lang.Integer⠤���8 I valuexr java.lang.Number������  xp   t 系统sq ~  xF� xsq ~ psq ~  xF� xsq ~ 

   t "[truncated 297 bytes]; line: 1, column: 2]

at org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer.deserialize(Jackson2JsonRedisSerializer.java:75)

at org.springframework.data.redis.serializer.DefaultRedisElementReader.read(DefaultRedisElementReader.java:48)

at org.springframework.data.redis.serializer.RedisSerializationContext$SerializationPair.read(RedisSerializationContext.java:272)

at org.springframework.data.redis.cache.RedisCache.deserializeCachevalue(RedisCache.java:260)

at org.springframework.data.redis.cache.RedisCache.lookup(RedisCache.java:94)

at org.springframework.cache.support.AbstractValueAdaptingCache.get(AbstractValueAdaptingCache.java:58)

at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:73)

at org.springframework.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:554)

at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:519)

at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:401)

at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:345)

at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.ja
加载更多
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/288334.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号