fasterxml.jackson 將對象轉換爲json報錯處理

查詢數據遇到如下報錯:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disableSerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.xwj.entity.UserEntity_$$_jvst57f_0["handler"])

觀察紅色字體部分,發現是實體類中有的字段值爲null,所以在json化的時候,fasterxml.jackson將對象轉換爲json報錯

解決辦法:

  在實體類上面加上註解 @JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章