BUG描述:
Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
解决过程:
发现可能是版本兼容问题,我用的是spring4.0.3,hibernate是5.2.6,在配置事务管理的时候需要引入
org.springframework.orm.hibernate5.HibernateTransactionManager,一开始我引入的是4,即
org.springframework.orm.hibernate4.HibernateTransactionManager
所以报错,但是spring-orm-4.0.5RELEASE里面没有5,只有3跟4,所以,我将这个jar化成了spring-orm-4.3.6.RELEASE,里面有345,换好后,又出现新的问题
找到问题所在
箭头所指的地方原来是3,改成5,程序正常
这个时候想起spring-orm-4.0.5.RELEASE是不是也能配hibernate5,于是又将jar换回原来的,将两个地方的引用都换成4
结果不行,4.0.5的spring不能匹配5.2.6的hibernate。
当然,我这里可能只是特例,可能是其他原因,这里给出一种猜测和解决方法。