使用hibernate5配置transaction时session.beginTransaction()报错

在使用eclipse配置hibernate5时Transaction transaction = session.beginTransaction();开启一个新的事务时报错。

eclipse报错内容如下:

The type java.lang.AutoCloseable cannot be resolved. It is indirectly referenced from required .class file


解决方法:

如果碰到以上错误,检查自己的jdk版本。最好使用jdk8以上的版本,原因如下:

http://docs.jboss.org/hibernate/search/4.1/reference/en-US/html/getting-started.html

官网上有句话说明:


Java Runtime A JDK or JRE version 6 or greater. You can download a Java Runtime for Windows/Linux/Solaris here. If using Java version 7 make sure you avoid builds 0 and 1: those versions contained an optimisation bug which would be triggered by Lucene. Hibernate Search 3.x was compatible with Java version 5.


你可能感兴趣的:(J2EE,hibernate,hibernate)