在用springboot根据id获取一个对象时出现以下异常:
Type definition error: [simple type, class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
原因是查出内容包含空值。
解决方法:
在相应的实体类添加如下注解:
@JsonIgnoreProperties({"hibernateLazyInitializer","handler"})