fasterxml.jackson.databind.exc.InvalidDefinitionException 将对象转换为json报错处理

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)