我不断收到:
HibernateException: No CurrentSessionContext configured!
在我的代码中。其他搜索返回的唯一信息是罪魁祸首是:
<property name="current_session_context_class">thread</property>
在我的 hibernate.cfg.xml 中。我的 hibernate.cfg.xml 文件中有它,我在 Tomcat 6 中运行它。有人知道其他可能的原因吗?
最佳答案
我相信你需要将你的 current_session_context_class 设置为一个实际的类......我有我的 hibernate.cfg.xml 配置如下:
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
上面的代码用于 mySql 数据库,但我认为数据库对于上述属性的类型并不重要
希望这可以帮助
关于 hibernate :未配置 CurrentSessionContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/761480/