Hibernate4.x与spring3.x整合,有关事务的处理,用Junit4测试,出现org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txManager' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/SessionFactoryImplementor;

 
xml主要配置信息:
   
 <bean  
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="annotatedClasses">
    <list>
    <value>com.li.bean.User</value>
    <value>com.li.bean.Log</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
  </bean>
  <bean  
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="txManager"/>

 

解决办法:并不是缺少jar包。目前spring3.x已经支持hibernate4.x。所以有些以前的hibernate3字眼改成hibernate4即可!正如
<bean  
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">与
<bean  
   class="org.springframework.orm.hibernate3.HibernateTransactionManager">改成
<bean  
   class="org.springframework.orm.hibernate4.HibernateTransactionManager">
即可!
不出现报错了!

相关文章:

  • 2021-04-24
  • 2021-09-03
  • 2021-10-04
  • 2021-04-09
  • 2021-12-14
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
相关资源
相似解决方案