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>
  • 相关阅读:
    MongoDB 分片管理(一)检查集群状态
    MongoDB 副本集
    MongoDB 集群设置集合分片生效及查看集合分片情况
    mongodb 导入json文件遇到的坑
    GreenPlum/postgres copy命令导出/导入数据
    Mongo mongoexport/mongoimport介绍
    mongoDB之监控工具mongostat
    Oracle ORA-00600[2662] 解决
    ORA-00600[2662]问题 汇总
    MySQL的基本使用
  • 原文地址:https://www.cnblogs.com/amosli/p/3455026.html
Copyright © 2011-2022 走看看