小编典典

java.lang.ClassNotFoundException:org.hibernate.engine.SessionFactoryImplementor

hibernate

我正在尝试使用 Spring 3.1.1.RELEASE* 迁移到hibernate 4.1.0.Final , 以下是我对hibernate的配置: *

    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="${project.groupId}.domain" />


    <!-- control the behavior of Hibernate at runtime,All are optional and 
        have reasonable default values -->
    <property name="hibernateProperties">
        <value>
            <!-- hibernate.dialect: allows Hibernate to generate SQL optimized for 
                a particular relational database -->
            hibernate.dialect=org.hibernate.dialect.MySQLDialect
            hibernate.hbm2ddl.auto=create-drop
            hibernate.show_sql=false
            hibernate.jdbc.fetch_size=100
            hibernate.jdbc.batch_size=100
            hibernate.jdbc.batch_versioned_data=true
            hibernate.order_inserts=true
            hibernate.order_updates=true
            hibernate.cache.use_query_cache=false
            hibernate.cache.use_second_level_cache=false

        </value>
    </property>


</bean>

<!-- provides properties to hibernate to make it able to create session 
    factory. Hibernate uses instance of session bean of type -->
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">

    <property name="driverClassName" value="com.mysql.jdbc.Driver" />

    <property name="url" value="${db.url}" />

    <property name="username" value="${db.username}" />

    <property name="password" value="${db.password}" />

</bean>

<!-- responsible for creating sessionFactory opening transactions and binding 
    them to the current thread context. -->
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    <property name="nestedTransactionAllowed" value="true" />
</bean>

<!-- get exception translation from HibernateException into DataAccessException 
    hierarchy -->
<bean
    class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

但是当尝试运行该应用程序时,出现以下异常:

 java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)

请告知为什么我收到此错误,以及如何解决它,谢谢。


阅读 230

收藏
2020-06-20

共1个答案

小编典典

尝试使用 org.springframework.orm.hibernate4.HibernateTransactionManager

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="dataSource" ref="dataSource" />
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
2020-06-20