spring配置文件报java.lang.NoClassDefFoundError: org.hibernate.engine.SessionFactory

来源:互联网 发布:淘宝多久不会查这么严 编辑:程序博客网 时间:2024/05/02 15:30

在整合spring3.x和hibernate4.x初始化启动之后出现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: 

applicationContext.xml部分配置文件如下:

<!-- 定义事务管理器(声明式的事务) -->  
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>


    <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="is*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
    </tx:advice>
    
    <aop:config>
        <aop:pointcut id="interceptorPointCuts"
            expression="execution(* biz.impl.*BizImpl.*(..))" />
        <aop:advisor advice-ref="txAdvice"
            pointcut-ref="interceptorPointCuts" />        
    </aop:config> 

其实并不是因为出现jar原因,是因为目前spring3.x可以支持hibernate4.x,故只需将class="org.springframework.orm.hibernate3.HibernateTransactionManager"改为class="org.springframework.orm.hibernate4.HibernateTransactionManager"后,重新启动就没问题了。