Spring data Jpa 查询时出现的异常

发布于 2020-08-12  982 次阅读


[title]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.ByteBu[/title]

解决方案:

在实体类中添加了一下注解后 解决了问题

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

需要在查询涉及的类上加上注解@JsonIgnoreProperties(value={“hibernateLazyInitializer”,“handler”})
作用是在 json 序列化时忽略 bean 中的一些不需要转化的属性

一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。