1、在application.yml中添加
1 spring.jpa.open-in-view: true
2、在使用查询的方法添加
@Transactional
SpringBoot 使用JPA时解决no session的方法
原文:https://www.cnblogs.com/famary/p/10333489.html