Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Co
来源:互联网 发布:淘宝特卖是什么 编辑:程序博客网 时间:2024/06/08 00:59
Failed to write HTTP message: 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); nested exception is com.fasterxml.jackson.databind.JsonMappingException: 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: com.Controller.User_$$_jvstdcc_0["handler"])
在spring boot框架中出通过id查询数据的时候出现的这个问题,
是因为查询的数据返回时空出现的异常:
使用来个一个注解,添加在实体类上就可以解决了
@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" })
这个注解的含义:
在此标记不生成json对象的属性
因为jsonplugin用的是java的内审机制.hibernate会给被管理的pojo加入一个hibernateLazyInitializer属性,jsonplugin会把hibernateLazyInitializer也拿出来操作,并读取里面一个不能被反射操作的属性就产生了这个异常.
不过我用的是jackson来转json,所以想到了用annotation来排除hibernateLazyInitializer 这个属性
在你的pojo类声明加上:
- @JsonIgnoreProperties(value={"hibernateLazyInitializer"})
- Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Co
- org.springframework.http.converter.HttpMessageNotWritableException:
- org.springframework.http.converter.HttpMessageNotWritableException:
- org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Infinite r
- Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Cou
- Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Cou
- [Spring+MyBatis3]关联查询(延迟加载)抛错误 org.springframework.http.converter.HttpMessageNotWritableException
- 经检查,各种没问题,但是前台500。后台org.springframework.http.converter.HttpMessageNotWritableException
- org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
- org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
- org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
- org.springframework.http.converter.HttpMessageNotReadableException异常
- org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
- org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
- java.lang.ClassNotFoundException: org.springframework.http.converter.json.MappingJacksonHttpMessageC
- Not found org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
- Not found org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
- Not found org.springframework.http.converter.json.MappingJacksonHttpMessageConve
- js如何实现图片一直停留在手机屏幕底部
- 数学之美~阅读
- 第十三周项目二
- 【第十五周项目1】验证算法——希尔排序
- 常见bug即原因集
- Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Co
- CentOS7下搭建zookeeper单机环境
- 用C打印9×9乘法口诀表
- tensorflow交叉熵理解
- ubuntu 14 本地源制作
- android 一个混合框架的使用
- 系统休眠(System Suspend)和设备中断处理
- 第7周 【项目4】 队列数组
- 支付宝公钥和rsa私钥配置