当spring boot单独集成jpa,开启hibernate的懒加载机制时没有问题,然而再集成shiro后运行过程中就会报错could not initialize proxy - no Session。

针对此问题,在网上找到的比较合理的解决方案是增加openSessionInViewFilter,并保证此filter在shiroFilter前面。

【问题记录1】Spring Boot集成jpa+shiro报错could not initialize proxy - no Session解决方案

@Bean
public SessionFactory sessionFactory(@Qualifier("entityManagerFactory") EntityManagerFactory emf){
    return emf.unwrap(SessionFactory.class);
}
注:此方案必须声明sessionFactory(上述声明过程不确定是否有问题)。

经过验证在spring boot中此方案未能解决问题(可能是我项目配置或者相关包版本原因,感觉应该是sessionFactory获取过程不对),最终找到解决方案是:

增加OpenEntityManagerInViewFilter。

【问题记录1】Spring Boot集成jpa+shiro报错could not initialize proxy - no Session解决方案

问题得以解决。

感谢:https://blog.csdn.net/lzwglory/article/details/18655431

相关文章:

  • 2022-12-23
  • 2022-02-21
  • 2021-08-19
  • 2021-08-20
  • 2021-12-09
猜你喜欢
  • 2021-07-20
  • 2021-05-03
  • 2021-07-15
  • 2022-12-23
  • 2021-09-07
  • 2022-01-18
  • 2021-04-27
相关资源
相似解决方案