zoukankan      html  css  js  c++  java
  • 解决"No CurrentSessionContext configured"错误(转)

    解决"No CurrentSessionContext configured"错误 (2008-07-01 14:16:25)

    用Hibernate开发遇到"No CurrentSessionContext configured"错误

    在使用SessionFactory的getCurrentSession方法时遇到如下错误,经过检查,原因如下:

    是因为在hibernate.cfg.xml文件中忘记进行了如下设置:hibernate.current_session_context_class

    如果是在web容器中运行hibernate,则在hibernate.cfg.xml中加入这句话:

    <property name="hibernate.current_session_context_class">jta</property>

    如果是在一个单独的需要进行JDBC连接的java application中运行hibernate,则这样设置:

    <property name="hibernate.current_session_context_class">thread</property>

    本文属于转帖。

    我今天学习hibernate的时候遇见次错误,在配置文件里面加上之后,问题解决。

  • 相关阅读:
    9.5(day3)
    9.4(day2)
    web第一阶段 9.3(day1)
    8.29
    8.28
    8.27
    8.24
    dockerfile的编写
    深入解析pod对象的基本概念
    k8s最小调度pod的概念
  • 原文地址:https://www.cnblogs.com/m3Lee/p/3382836.html
Copyright © 2011-2022 走看看