2018-11-01 13:43:52.241 ERROR 651080 --- [nio-8081-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : 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: girl.mooc.demo.Girl$HibernateProxy$mzIoTDAm["hibernateLazyInitializer"])] with root cause
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: girl.mooc.demo.Girl$HibernateProxy$mzIoTDAm["hibernateLazyInitializer"])
解决办法:
在对应的实体类上面加上注解 @JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
本文详细介绍了在使用Spring框架进行数据处理时遇到的序列化异常问题,具体表现为HttpMessageConversionException错误,其根本原因是Jackson无法正确序列化Hibernate的代理对象。文中提供了解决方案,即在实体类上添加@JsonIgnoreProperties注解来排除特定属性,从而避免了异常的发生。

133

被折叠的 条评论
为什么被折叠?



