序列化List <object>时没有序列化程序发现错误

时间:2017-01-18 18:20:31

标签: java spring jackson

我有一个班级

public class ClassB 
{

    private ClassC c;

    private List<ClasssA> a;

}

我在我的控制器方法中作为响应体返回。当我将@JsonIgnore添加到List对象时,我得到了响应但是当我包含List时,我收到错误

Could not write content: 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) ) (through reference chain: ......

1 个答案:

答案 0 :(得分:0)

这是

的常见问题
  

延迟Hibernate加载:Hibernate不会加载该特定对象实例的关系。

这就是你得到错误的原因。现在常见的解决方案和报告的错误是使用此属性

@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})

查看更多此Bug Reported及更多Lazy vs Eager

相关问题