gpt4 book ai didi

java - java中出现hibernate session 错误

转载 作者:行者123 更新时间:2023-12-01 19:18:44 26 4
gpt4 key购买 nike

我有这个

SessionFactory sessionFactory = new AnnotationConfiguration()
.configure("com/vaannila/service/hibernate.cfg.xml")
.buildSessionFactory();

Session session = sessionFactory.getCurrentSession();

我收到此错误

org.hibernate.HibernateException: No CurrentSessionContext configured!
org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:542)

最佳答案

您必须在 hibernate.xml 文件中设置 hibernate.current_session_context_class。

引用以下内容:http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-j2ee-currentsession

关于java - java中出现hibernate session 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5448454/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com