1. 程式人生 > 其它 >Redis快取查詢時報欄位無法識別問題-SerializationException: Could not read JSON: Unrecognized xxx

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類中缺少對應的欄位

只有get方法,沒有實體欄位

加上對應的實體欄位就好沒問題了