fasterxml.jackson 将对象转换为json报错处理

xiaoxiao2025-04-29  17

最近在做查询的数据遇到如下报错:

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, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.xwj.entity.UserEntity_$$_jvst57f_0["handler"])

仔细看红色字体部分,发现是实体类中有的字段值为null,所以在json化的时候,fasterxml.jackson将对象转换为json报错

解决办法:

  在实体类上面加上注解 @JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })

转载请注明原文地址: https://www.6miu.com/read-5029413.html

最新回复(0)