Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured!
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:685)
at com.yjw.service.StudentService.main(StudentService.java:19)
原因是hibernate.cfg.xml中没有配置正确,如果是web应用增加配置
Java代码
<property name="current_session_context_class">jta</property>
如果是Java应用,增加如下配置
Java代码
<property name="current_session_context_class">thread</property>
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:685)
at com.yjw.service.StudentService.main(StudentService.java:19)
原因是hibernate.cfg.xml中没有配置正确,如果是web应用增加配置
Java代码
<property name="current_session_context_class">jta</property>
如果是Java应用,增加如下配置
Java代码
<property name="current_session_context_class">thread</property>
本文解析了Hibernate抛出的一个常见异常:NoCurrentSessionContext configured,并提供了针对Java应用和Web应用的配置解决方案。
1150

被折叠的 条评论
为什么被折叠?



