欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jpa实体jackson问题

程序员文章站 2022-03-04 09:06:02
...
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.HashMap["data"]->com.xx.jpa.Info_$$_jvstf63_0["handler"])
at org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52)



解决方法:
@Entity
#加入下面这行
@JsonIgnoreProperties(value = { "handler", "hibernateLazyInitializer" })
public class Info implements Serializable {