问题描述
严重:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname'sessionFactory'definedinServletContextresource[/WEB-INF/applicationContext.xml]:Unsatisfieddependencyexpressedthroughbeanproperty'eventListeners'::Errorcreatingbeanwithname'userDao'definedinServletContextresource[/WEB-INF/applicationContext.xml]:Cannotresolvereferencetobean'sessionFactory'whilesettingbeanproperty'sessionFactory';nestedexceptionisorg.springframework.beans.factory.BeanCurrentlyInCreationException:Errorcreatingbeanwithname'sessionFactory':FactoryBeanwhichiscurrentlyincreationreturnednullfromgetObject;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'userDao'definedinServletContextresource[/WEB-INF/applicationContext.xml]:Cannotresolvereferencetobean'sessionFactory'whilesettingbeanproperty'sessionFactory';nestedexceptionisorg.springframework.beans.factory.BeanCurrentlyInCreationException:Errorcreatingbeanwithname'sessionFactory':FactoryBeanwhichiscurrentlyincreationreturnednullfromgetObjectatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1150)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1040)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4334)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)atorg.apache.catalina.core.StandardHost.start(StandardHost.java:719)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)atorg.apache.catalina.core.StandardService.start(StandardService.java:516)atorg.apache.catalina.core.StandardServer.start(StandardServer.java:710)atorg.apache.catalina.startup.Catalina.start(Catalina.java:566)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'userDao'definedinServletContextresource[/WEB-INF/applicationContext.xml]:Cannotresolvereferencetobean'sessionFactory'whilesettingbeanproperty'sessionFactory';nestedexceptionisorg.springframework.beans.factory.BeanCurrentlyInCreationException:Errorcreatingbeanwithname'sessionFactory':FactoryBeanwhichiscurrentlyincreationreturnednullfromgetObjectatorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1308)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:825)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:754)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:685)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1134)...37moreCausedby:org.springframework.beans.factory.BeanCurrentlyInCreationException:Errorcreatingbeanwithname'sessionFactory':FactoryBeanwhichiscurrentlyincreationreturnednullfromgetObjectatorg.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:157)atorg.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:109)atorg.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1387)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:244)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)...50more那位大虾帮我看看是什么错,我是初学者,搞不懂,谢谢
解决方案
解决方案二:
欢迎加我QQ交流:254971553
解决方案三:
可能是[/WEB-INF/applicationContext.xml中的问题
解决方案四:
那具体是哪里的问题呢
解决方案五:
有一个包导错了,就是在SessionFactory第一次出现的位置下面的那个包,你改改,就好了,org.springwork.jdbc.datasource.d.....可能写得不对,你点就出来了,忘了,
解决方案六:
该回复于2011-04-19 15:05:36被版主删除
解决方案七:
代码贴出来瞅瞅
解决方案八:
两种可能(1):userDao所在的实例类没提供get,set方法(2):spring配置文件与userDao属性对应实例类中名字不一样(userDao)。
解决方案九:
引用3楼yl521239的回复:
那具体是哪里的问题呢
代码贴出来呀
解决方案十:
<beansxmlns="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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd"default-autowire="byType"><!--数据源--><beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><propertyname="driverClassName"><value>com.mysql.jdbc.Driver</value></property><!--修改数据库用户名密码--><propertyname="url"><value>jdbc:mysql://localhost:3306/ssh</value></property><propertyname="username"><value>root</value></property><propertyname="password"><value>521239</value></property></bean><beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><propertyname="dataSource"><reflocal="dataSource"/></property><propertyname="mappingResources"><list><value>com/bean/User.hbm.xml</value></list></property><propertyname="hibernateProperties"><props><propkey="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop><propkey="hibernate.show_sql">true</prop></props></property></bean><!--dao--><beanid="userDao"class="com.dao.impl.UserDAOImpl"scope="singleton"><propertyname="sessionFactory"><reflocal="sessionFactory"/></property></bean><!--service--><beanid="userService"class="com.service.impl.UserServiceImpl"scope="singleton"><propertyname="userDao"><reflocal="userDao"/></property></bean><beanid="userAction"class="com.action.user.UserAction"scope="prototype"><propertyname="service"ref="userService"></property></bean></beans>
解决方案十一:
感觉LZ贴出来applicationContext.xml代码好熟悉啊、貌似是哪个网页里面的、、、
解决方案十二:
照到写的,其他都一样,怎么就错了??郁闷