Redis缓存查询时报字段无法识别问题-SerializationException: Could not read JSON: Unrecognized xxx


报错信息:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Unrecognized field "houseType4Search" (class com.haoke.pojo.Item), not marked as ignorable (15 known properties: "isRented", "img", "price", "city", "sales", "info", "imgs", "rentType", "title", "recommendation", "houseType", "id", "recoSort", "buytime", "link"])
at [Source: (byte[])"{"@class":"com.haoke.pojo.Item","id":"6216363d9ba8811e82099417","title":"北京老小区","sales":300,"recommendation":true,"recoSort":9,"city":"北京","price":3000,"rentType":"整租","houseType":"60 ㎡","houseType4Search":"6/6层|2室1厅-60 ㎡","info":{"@class":"java.util.LinkedHashMap","orientation":"朝南","level":"6/6层","style":"简单装修","type":"2室1厅","years":"2000"},"imgs":["java.util.ArrayList",["http://192.168.136.130:80/group1/M00/00/00/wKiIgmITgQmAF1htAAuC467ZRns833_big"[truncated 368 bytes]; line: 1, column: 228] (through reference chain: com.haoke.pojo.Item["houseType4Search"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "houseType4Search" (class com.haoke.pojo.Item), not marked as ignorable (15 known properties: "isRented", "img", "price", "city", "sales", "info", "imgs", "rentType", "title", "recommendation", "houseType", "id", "recoSort", "buytime", "link"])
at [Source: (byte[])"{"@class":"com.haoke.pojo.Item","id":"6216363d9ba8811e82099417","title":"北京老小区","sales":300,"recommendation":true,"recoSort":9,"city":"北京","price":3000,"rentType":"整租","houseType":"60 ㎡","houseType4Search":"6/6层|2室1厅-60 ㎡","info":{"@class":"java.util.LinkedHashMap","orientation":"朝南","level":"6/6层","style":"简单装修","type":"2室1厅","years":"2000"},"imgs":["java.util.ArrayList",["http://192.168.136.130:80/group1/M00/00/00/wKiIgmITgQmAF1htAAuC467ZRns833_big"[truncated 368 bytes]; line: 1, column: 228] (through reference chain: com.haoke.pojo.Item["houseType4Search"])] with root cause

究其原因时pojo类中缺少对应的字段

image

只有get方法,没有实体字段

image

加上对应的实体字段就好没问题了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM