在用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
註解:
@JsonIgnoreProperties({"hibernateLazyInitializer","handler"})