WE ARE COMMITTED TO INNOVATE FOR ALL MANKIND NO MATTER IF RAIN OR SHINE

给时光以生命,给岁月以文明。

JPA 懒加载带来的问题

原理暂不清楚,先记录待解决。

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: top.harmonytqs.entity.Demo$HibernateProxy$wprVXf6u["hibernateLazyInitializer"])

解决方法:在实体类上加上如下注解

//忽略序列化:在 json 序列化时忽略bean中的一些不需要转化的属性
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
posted @ 2021-09-02 17:51  缓进则退不进则亡  阅读(41)  评论(0编辑  收藏  举报