Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for cl

不屑哥發表於2020-12-18

參考:https://blog.51cto.com/12012821/2368259

spring boot使用jpa查詢返回實體後,返回介面時候json格式化出錯

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.winyo.commonstarter.model.ServiceResult["data"]->com.winyo.shop.entity.User$HibernateProxy$RIMO4ULm["hibernateLazyInitializer"])

實體類加上註解即可

@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })

 

相關文章