gpt4 book ai didi

java - Bean创建异常: Error creating bean with name 'sessionFactory'

转载 作者:行者123 更新时间:2023-11-30 05:00:54 25 4
gpt4 key购买 nike

尝试创建 session 工厂时遇到以下问题。

javax.servlet.ServletException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [com/virtusa/ideas/util/spring.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'factory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/virtusa/ideas/util/spring.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer root cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [com/virtusa/ideas/util/spring.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'factory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/virtusa/ideas/util/spring.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer root cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/virtusa/ideas/util/spring.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer root cause java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer

Spring.xml

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.0.xsd" default-autowire="byName">

<!-- <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>-->


<bean id="userDao"
class="com.virtusa.ideas.util.HibernateUserDAO">
<property name="factory" ref="sessionFactory" />
</bean>


<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/virtusa/ideas/entity/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<!-- <props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>-->
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
</value>
</property>
</bean>


<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url" value="jdbc:mysql://localhost:3306/ideas" />
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>

</beans>

有人可以帮忙吗?

最佳答案

您缺少 hibernate 代码生成所需的 cglib jar。

关于java - Bean创建异常: Error creating bean with name 'sessionFactory' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6766724/

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