zoukankan      html  css  js  c++  java
  • spring hiberante 集成出现异常 java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor

    出现如题的异常是由于hibernate和spring集成时的的版本不一致所导致。

    如下面,所示,如果你用的hibneate 4.0及以上版本,那么将会报错,因为这里用的事务管理是hibernate 3.并非缺少什么jar包。

    org.springframework.orm.hibernate3.HibernateTransactionManager 
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                   http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                   http://www.springframework.org/schema/context
                   http://www.springframework.org/schema/context/spring-context-3.2.xsd
                   http://www.springframework.org/schema/tx
                   http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
                   http://www.springframework.org/schema/aop
                   http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
                   ">
        
        <!-- 配置一个SessionFactory,使用我们自己写的工具类来获取SessionFactory -->
        <bean id="mysessionFactory" class="com.amos.spring.dao.HibernateUtil" factory-method="getFactory">
        </bean>
        <!-- 配置一个使用HiberanteTemplate对象 -->
        <bean id="myTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="mysessionFactory"></property>
        </bean>
        <!-- 配置一个使用hibernateTemplate的dao-->         
        <bean id="accountDao"    class="com.amos.spring.dao.AccountDaoByHibernateTemplate">
        <property name="template" ref="myTemplate"></property>
        </bean>
        <bean id="transferService" class="com.amos.spring.service.TransferServiceImpl2">
        <property name="accountDao" ref="accountDao"></property>
        </bean>
        
        <!-- 配置事务管理 -->
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <!-- 事务管理器作用于哪个SessionFactory -->
        <property name="sessionFactory" ref="mysessionFactory"></property>
        </bean>
        <tx:annotation-driven transaction-manager="transactionManager"/>
    </beans>
  • 相关阅读:
    React.Fragment
    微信分享
    视频H5 video标签最佳实践
    详解vue2.0+vue-video-player实现hls播放全过程
    call()和appl()的理解
    JS 原生面经从初级到高级
    vue面试
    面试题2
    IdentityServer4 实现 OpenID Connect 和 OAuth 2.0
    DDD关键知识点整理汇总
  • 原文地址:https://www.cnblogs.com/amosli/p/3455026.html
Copyright © 2011-2022 走看看