啥也不说了,几乎折腾了我两天,各种配置删了又添都快不想使了,还好解决了,分享下:

org.hibernate.HibernateException: No CurrentSessionContext configured!

配置文件中添加

#配合解决Consider defining a bean of type 'org.hibernate.Session' in your configuration. 缺少的话报No CurrentSessionContext configured!

spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext

同时还有SessionFactory注入

/**
     * 注入sessionfatory
     * @return
     */
    @Bean
    public SessionFactory sessionFactory(HibernateEntityManagerFactory hemf) {
       return hemf.getSessionFactory();

    }

一块使才好使,移植过来的项目就是事多,希望能帮到各位。

相关文章:

  • 2021-09-02
  • 2022-12-23
  • 2021-10-06
  • 2021-07-12
  • 2022-12-23
  • 2022-01-12
  • 2021-09-29
  • 2021-06-04
猜你喜欢
  • 2021-12-24
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2021-05-21
  • 2021-08-26
相关资源
相似解决方案