严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through bean property 'eventListeners': : Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject配置如下:
<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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-autowire="byType">
<!-- 数据源 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<!-- 修改数据库用户名 密码 -->
<property name="url" >
<value>jdbc:mysql://localhost:3306/ssh</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>521239</value>
</property>
</bean>
<bean id="sessionFactory" class=
"org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>com/bean/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
</props>
</property>
</bean>
<!-- dao -->
<bean id="userDao" class="com.dao.impl.UserDAOImpl" scope="singleton">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- service -->
<bean id="userService" class="com.service.impl.UserServiceImpl" scope="singleton">
<property name="userDao" >
<ref local="userDao"/>
</property>
</bean>
<bean id="userAction" class="com.action.user.UserAction" scope="prototype">
<property name="service" ref="userService"></property>
</bean>
</beans>
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through bean property 'eventListeners': : Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject配置如下:
<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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-autowire="byType">
<!-- 数据源 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<!-- 修改数据库用户名 密码 -->
<property name="url" >
<value>jdbc:mysql://localhost:3306/ssh</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>521239</value>
</property>
</bean>
<bean id="sessionFactory" class=
"org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>com/bean/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
</props>
</property>
</bean>
<!-- dao -->
<bean id="userDao" class="com.dao.impl.UserDAOImpl" scope="singleton">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- service -->
<bean id="userService" class="com.service.impl.UserServiceImpl" scope="singleton">
<property name="userDao" >
<ref local="userDao"/>
</property>
</bean>
<bean id="userAction" class="com.action.user.UserAction" scope="prototype">
<property name="service" ref="userService"></property>
</bean>
</beans>
解决方案 »
- 在struts里使用泛型,谁用过,老是实例不了
- org.apache.catalina.core.StandardContext start 错误
- 文件上传到数据库后,下载无法得到数据
- oracle 备份与恢复 ???????
- 关于 jsp页面长时间不操作session失效并向数据库发送一个状态怎样及解决?
- 请教一个框架的问题!很急!谢谢了啊
- jar包运行时的找不到hibernate的映射问题,难度不小!
- 希望知道的人能回答下(问很多次没有人关心,是不会呢,还是。。。。),该怎么做,关于java如何读取sqlserver中的text类型的数据。这个问
- weblogic8.1 +struts +eclipse开发的配置文档
- 关于java多线程的问题
- Hibernate @ManyToOne保存问题
- ihs 不跳转was
web.xml是不是没配置东西,
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext*.xml
classpath:applicationContext*.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
参考: <context-param>
<param-name>contextConfigLocation</param-name>
<param-value> /WEB-INF/configs/applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
对象是否为null.
(2)你的userDAO这个类(或者父类)可能没有继承HibernateDaoSupport;