gpt4 book ai didi

java - Spring 3 与 Hibernate 3 注解 - session 工厂配置

转载 作者:行者123 更新时间:2023-12-01 05:43:28 25 4
gpt4 key购买 nike

我在为 Hibernate Annotations 配置 spring 配置文件时运气不佳。我一直在看其他帖子,但不确定我错过了什么。我不需要定义配置文件,因为我在 session 工厂中使用 HibernateProperties 是否正确?我收到以下错误:

错误消息

创建名为“HibernateSessionFactory”的 bean 时出错

无法实例化bean类[org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]:构造函数抛出异常;嵌套异常是 java.lang.NoClassDefFoundError: org.hibernate.cfg.AnnotationConfiguration

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

Spring 配置

<!--     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>

enter image description here

最佳答案

Hibernate Annotations jar 是否在您的类路径中?

关于java - Spring 3 与 Hibernate 3 注解 - session 工厂配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6506280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com