Error tip: caused By:java.lang.ClassNotFoundException:org.hibernte.engine.transaction.spi.transactioncontext
I use the hibernate version of 5.2.5,spring for 4.6.1.
Error configuration in Applicationcontext.xml:
<!--3. Configure Sessionfactory instances of Hibernate, configured with the Localsessionfactorybean class provided by spring-
<bean id= "Sessionfactory"
Class= "Org.springframework.orm.hibernate4. Localsessionfactorybean ">
<!--introducing data sources--
<property name= "DataSource" ref= "DataSource" ></property>
<!--introduce Hibernate profile--
<property name= "configlocation" value= "Classpath:hibernate.cfg.xml" ></property>
Integration with XML configuration in <!--hibernate
Introducing a bean mapping
<property name= "mappinglocations" value= "Classpath:*.hbm.xml" ></property>
-
<!--hibernate annotation Configuration Integration
The Annotatedclasses property is used here to take effect, not the Packagetoscan property.
-
<property name= "Annotatedclasses" >
<list>
<value>com.entity.Account</value>
<value>com.entity.Book</value>
</list>
</property>
</bean>
<!--4. Configure spring's claims transaction management-
<!--4.1 Configuration transaction Manager--
<bean id= "TransactionManager"
Class= "Org.springframework.orm.hibernate4.Hibernatetransactionmanager ">
<!--join Hibernate's Sessionfactory instance--
<property name= "Sessionfactory" ref= "Sessionfactory" ></property>
</bean>
<!--4.2 Configuring transaction properties requires transaction manager--
<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >
<tx:attributes>
<tx:method name= "get*" read-only= "true"/>
<!--other ways to use default values--
<tx:method name= "*"/>
</tx:attributes>
</tx:advice>
<!--4.3 Configure a transaction pointcut and associate the tangency point with the transaction properties-
<aop:config>
<aop:pointcut expression= "Execution (* com.service.*.* (..))"
Id= "Txpointcut"/>
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "Txpointcut"/>
</aop:config>
Workaround: Hibernate is version 5.0, and Spring is version 4.0. The class was canceled in the corresponding package in the 5.0 version of Hibernate. When configured in spring, we can only configure to hibernate4, so this problem occurs.
The solution is very simple, go to download hibernate4.0 version of Hibernate-core-4.3.8.final.jar Online, replace the one in 5.0 with this file. Run now and you'll be working properly.
Spring integration hibernate times wrong: Org.hibernte.engine.transaction.spi.transactioncontext