us 500 - Could not write content: could not initialize proxy - no Session (through reference chain: cn.jiedada.aisell.common.UIPage["rows"]->java.util.UnmodifiableRandomAccessList[0]->cn.jiedada.aisell.domain.Employee["department"]->cn.jiedada.aisell.domain.Department_$$_jvst583_0["id"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: could not initialize proxy - no Session (through reference chain: cn.jiedada.aisell.common.UIPage["rows"]->java.util.UnmodifiableRandomAccessList[0]->cn.jiedada.aisell.domain.Employee["department"]->c
因为hibernate的底层是通过session来实现CRUD,所以当关闭EntityManager时候所以会出现这个异常
在web.xml中配置
<!--解决获取部门懒加载noSession,配置JPA:OpenEntityMangerInViewFilter/Hibernater:OpenSessionMangerInViewFilter--> <!--Spring集成JPA必须配置--> <filter> <filter-name>OpenEntityMangerInViewFilter</filter-name> <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>OpenEntityMangerInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ———————————————— 版权声明:本文为CSDN博主「布谷_」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/qq_42136250/article/details/88581844