欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

org.hibernate.LazyInitializationException: could not initialize proxy [xxxx] - no Session异常

程序员文章站 2022-04-18 22:54:15
...

这是由于hiberante的懒加载机制出现的问题

以下在SpringBoot项目中的两种解决方案

第一种是在实体类上加上注解

@Proxy(lazy = false)

第二种是在配置文件application.properties中加入

spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true