redisson get()数据报错,missing type id property ‘@class’
生活随笔
收集整理的這篇文章主要介紹了
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的序列化使用SerializationCodec
② 實體類實現 Serializable 接口,添加serialVersionUID屬性。
③ 刪除redis數據,重試
總結
以上是生活随笔為你收集整理的redisson get()数据报错,missing type id property ‘@class’的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql查询字段大小写结果相同,mys
- 下一篇: go build 编译报错 missin