启动类中加入
@Bean
public OpenEntityManagerInViewFilter openEntityManagerInViewFilter(){
return new OpenEntityManagerInViewFilter();
}
配置文件中加入 spring.jpa.open-in-view=true
参考
解决Spring Data JPA延迟加载no session错误 http://blog.csdn.net/chrislyl/article/details/54630413