日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

JsonMappingException: Problem deserializing 'setterless' property '': get method returned null

發布時間:2023/12/18 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JsonMappingException: Problem deserializing 'setterless' property '': get method returned null 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

更改了一下實體類,往實體中添加一個字段之后,接口調用出錯了,控制臺打印的錯誤信息,而且也挺奇怪的,這里只是顯示了一個warning而不是error

2017-12-27 11:16:34.499 WARN 8640 --- [io-8099-exec-10] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Problem deserializing 'setterless' property 'foreignJoinFields': get method returned null; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing 'setterless' property 'foreignJoinFields': get method returned nullat [Source: java.io.PushbackInputStream@4dba74ee; line: 1, column: 927] (through reference chain: com.hyk.controller.parameter.RequestParameter["fields"]->java.util.ArrayList[0]->com.hyk.jdbc.Field["foreignJoinFields"] 我的實體類Field中有一個foreignJoinFields字段,是一個List,,代碼如下:
public class Field {// 省略其他字段和getter、setter方法private List<Field> foreignJoinFields;public List<Field> getForeignJoinFields() {return foreignJoinFields;}public void setForiegnJoinFields(List<Field> foriegnJoinFields) {this.foreignJoinFields = foriegnJoinFields;} } 看到出現這樣的錯誤我也首先想到是方法的問題,反序列化為模型肯定是和getter/setter方法有關,但是貌似看起來都沒有什么問題,后來仔細挨個對比,發現get中的foreign到了set方法中寫成了foriegn,而且set方法中的參數也寫錯了,導致了前端發送請求反序列化時出現錯誤。更改之后:
public class Field {// 省略其他字段和getter、setter方法private List<Field> foreignJoinFields;public List<Field> getForeignJoinFields() {return foreignJoinFields;}public void setForeignJoinFields(List<Field> foreignJoinFields) {this.foreignJoinFields = foreignJoinFields;} } 所以如果遇到這個問題,檢查一下getter和setter方法吧。

總結

以上是生活随笔為你收集整理的JsonMappingException: Problem deserializing 'setterless' property '': get method returned null的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。