ㄓㄤㄑㄧㄤ

HttpMessageNotWritableException: Could not write JSON: No serializer found for class ****

今天碰到一个异常,下面是错误信息

org.springframework.http.converter.HttpMessageNotWritableException:   
Could not write JSON: 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) )   

根据提示,大致的意思应该是City类在转化为json时,有属性值是null,最后我在City类中加入了下面的一句代码

@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" })
问题得到了解决,需要值得注意的是:我的工程中有两个JsonIgnoreProperties注解,分别是:
org.codehaus.jackson.annotate.JsonIgnoreProperties;
和com.fasterxml.jackson.annotation.JsonIgnoreProperties;
应该使用com.fasterxml.jackson.annotation.JsonIgnoreProperties;
参考:http://blog.csdn.net/switch_zyp/article/details/50633629
posted @ 2017-03-02 19:34  ㄓㄤㄑㄧㄤ  阅读(7252)  评论(0编辑  收藏  举报
哈哈,页脚部分。