redisson get()数据报错,missing type id property ‘@class’

redisson get()数据报错:

com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class java.lang.Object]: missing type id property ‘@class’

详细报错信息如下:
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class java.lang.Object]: missing type id property '@class'
xxxx
xxxx
[ERROR] 2021-11-29 17:52:59.114 [redisson-netty-2-11] ErrorsLoggingHandler.exceptionCaught(47) - Exception occured. Channel: [id: 0x14385c74, L:/172.16.101.17:60939 - R:xxx.201.34.xxx/xxx.201.34.2xx:6379]
io.netty.handler.codec.DecoderException: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class java.lang.Object]: missing type id property '@class'
 at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 104]
xxx
xxx
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class java.lang.Object]: missing type id property '@class'
报错原因:

json序列化转换失败,找不到名为“@class”的property

1. 解决方法一:

① 在实体类上添加注解:

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS,include = JsonTypeInfo.As.PROPERTY,property = "@class")

② 添加无参构造方法
③ 删除redis数据,重试

2. 解决方法二:

① 修改序列化器,支持以下序列化器,java的序列化使用SerializationCodeclQLPDhrpxJZNoprNBBTNApSwT2YQW1oT7q0BrD-HKUBIAA_660_1044.png_720x720g

② 实体类实现 Serializable 接口,添加serialVersionUID属性。
③ 删除redis数据,重试

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

了迹奇有没

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值