栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Could not write JSON: could not initialize proxy [com.example.demo.bean.Account#2] - no Session;

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Could not write JSON: could not initialize proxy [com.example.demo.bean.Account#2] - no Session;

Could not write JSON: could not initialize proxy [com.example.demo.bean.Account#2] - no Session;
问题描述:

Could not write JSON: could not initialize proxy
[com.example.demo.bean.Account#2] - no Session; nested exception is
com.fasterxml.jackson.databind.JsonMappingException: could not
initialize proxy [com.example.demo.bean.Account#2] - no Session
(through reference chain:
com.example.demo.bean.Account H i b e r n a t e P r o x y HibernateProxy HibernateProxyefC7Ku3G[“name”]):


原因分析:

导致这一问题的原因是:json序列化我们的实体类时,我们的实体类还没有成功加载。即懒加载晚于序列化导致。


解决方案:

在实体类这里加上这个注解@Proxy(lazy = false)

再运行,可以了

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/686063.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号