解决报错:nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException:

错误详情:

org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]; nested exception is 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)
在这里插入图片描述

原因:Json把懒加载也作为POJO进行序列化了。
解决方法:在该实体类的所有关联集合类上加上

@JsonIgnoreProperties({“ hibernateLazyInitializer”,“ handler”})
在这里插入图片描述

发布了74 篇原创文章 · 获赞 19 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_43770545/article/details/102707162