jackson序列化错误:com.fasterxml.jackson.databind.exc.InvalidDefinitionException

问题详情

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; 
nested exception is 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) 
(through reference chain: cn.ijunfu.utils.JSONData["data"]-
>org.springframework.data.domain.PageImpl["content"]-
>java.util.Collections$UnmodifiableRandomAccessList[0]-
>cn.ijunfu.modules.sys.entry.Menu["parent"]-
>cn.ijunfu.modules.sys.entry.Menu$HibernateProxy$vaSE5Gn9["hibernateLazyInitializer"])] with root cause

解决

在对应的实体类cn.ijunfu.modules.sys.entry.Menu上添加注解

@JsonIgnoreProperties(value = {"hibernateLazyInitializer"})

原因

实体类cn.ijunfu.modules.sys.entry.Menuparent字段值为null

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容