简体   繁体   中英

Spring 3 with Hibernate 3 Annotations - Session Factory Configuration

I am having very little luck configuring my spring config file for Hibernate Annotations. I have been looking at other posts and I'm not sure what I am missing. I shouldn't need to define a config file since I am using HibernateProperties in my session factory correct? I`m getting the following error:

Error Message

Error creating bean with name 'HibernateSessionFactory'

Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.hibernate.cfg.AnnotationConfiguration

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)

Spring Configuration

<!--     Defines the hibernate session factory to be used by the hibernate support dao classes -->
<bean id="HibernateSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
    <property name="dataSource" ref="webDataSrc" />
    <property name="annotatedClasses"> 
            <list> 
                    <value>ca.test.Foo</value> 
            </list> 
    </property>

    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="debug">true</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
            <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
        </props>
    </property>
</bean>

在此处输入图像描述

Is Hibernate Annotations jar on your classpath?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM