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>
  • 相关阅读:
    jQuery入门和DOM对象
    jQuery事件
    基础,层次,选择器
    MarkDown快速入门(typora)
    source是读入环境配置文件的命令,不能读入vimrc
    vi中将tab键转化为空格
    django-rest-framework学习之Quickstart和Serializer--2017年4月10日至12日
    Flask-RESTful插件介绍--2017年4月7日
    python restful api 编程--2017年4月6日
    一个验证登录的程序:python编写flask架构restful风格--2017年4月6日
  • 原文地址:https://www.cnblogs.com/amosli/p/3455026.html
Copyright © 2011-2022 走看看