日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

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

發(fā)布時(shí)間:2023/12/18 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JsonMappingException: Problem deserializing 'setterless' property '': get method returned null 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

更改了一下實(shí)體類,往實(shí)體中添加一個(gè)字段之后,接口調(diào)用出錯(cuò)了,控制臺打印的錯(cuò)誤信息,而且也挺奇怪的,這里只是顯示了一個(gè)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"] 我的實(shí)體類Field中有一個(gè)foreignJoinFields字段,是一個(gè)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;} } 看到出現(xiàn)這樣的錯(cuò)誤我也首先想到是方法的問題,反序列化為模型肯定是和getter/setter方法有關(guān),但是貌似看起來都沒有什么問題,后來仔細(xì)挨個(gè)對比,發(fā)現(xiàn)get中的foreign到了set方法中寫成了foriegn,而且set方法中的參數(shù)也寫錯(cuò)了,導(dǎo)致了前端發(fā)送請求反序列化時(shí)出現(xiàn)錯(cuò)誤。更改之后:
public class Field {// 省略其他字段和getter、setter方法private List<Field> foreignJoinFields;public List<Field> getForeignJoinFields() {return foreignJoinFields;}public void setForeignJoinFields(List<Field> foreignJoinFields) {this.foreignJoinFields = foreignJoinFields;} } 所以如果遇到這個(gè)問題,檢查一下getter和setter方法吧。

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。