问题描述
信息:CreationofSecureRandominstanceforsessionIDgenerationusing[SHA1PRNG]took[138]milliseconds.2013-12-1919:50:46org.apache.catalina.loader.WebappClassLoadervalidateJarFile信息:validateJarFile(D:workspace.metadata.pluginsorg.eclipse.wst.server.coretmp1wtpwebappsSpringWEB-INFlibservlet-api.jar)-jarnotloaded.SeeServletSpec2.3,section9.7.2.Offendingclass:javax/servlet/Servlet.class2013-12-1919:50:50org.apache.catalina.core.ApplicationContextlog信息:InitializingSpringrootWebApplicationContext19:50:52,083ERRORContextLoader:215-Contextinitializationfailedorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'addAction':Autowiringoffieldsfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatecom.tit.service.iface.IUserInfoServicecom.tit.action.AddAction.userInfoService;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'userInfoService':Autowiringoffieldsfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatecom.tit.dao.iface.IUserInfoDaocom.tit.service.impl.UserInfoService.userInfoDao;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'userInfoDao'definedinfile[D:workspace.metadata.pluginsorg.eclipse.wst.server.coretmp1wtpwebappsSpringWEB-INFclassescomtitdaoimplUserInfoDao.class]:Invocationofinitmethodfailed;nestedexceptionisjava.lang.IllegalArgumentException:'sessionFactory'or'hibernateTemplate'isrequiredatorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
解决方案
解决方案二:
'sessionFactory'或者'hibernateTemplate'配了没
解决方案三:
配置了。但是还是不行a
解决方案四:
<!--这表示spring将会在com.tit包下查找声明了@Component的类,并注册为springbean,同时还会检查bean中声明了@Autowired的属性,并自动注入该属性属性值--><context:component-scanbase-package="com.tit"/><!--配置数据源--><beanid="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource"><!--注入驱动--><propertyname="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property><!--注入URL--><propertyname="url"><value>jdbc:oracle:thin:@localhost:1521:NIIT</value></property><!--注入用户名--><propertyname="username"><value>system</value></property><!--注入密码--><propertyname="password"><value>tit</value></property></bean><beanid="txManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><propertyname="sessionFactory"ref="sessionFactory"/></bean><!--使用基于注解方式配置事务--><tx:annotation-driventransaction-manager="txManager"/><!--配置sessionFactory,整合hibernate--><beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><!--注入数据源--><propertyname="dataSource"><refbean="dataSource"/></property><!--配置hibernate属性--><propertyname="hibernateProperties"><props><!--方言--><propkey="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop><!--配置二级缓存插件--><propkey="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop><!--显示SQL语句--><propkey="hibernate.show_sql">true</prop></props></property><!--配置实体映射文件--><propertyname="mappingResources"><list><value>com/tit/pojo/UserInfo.hbm.xml</value><value>com/tit/pojo/Email.hbm.xml</value></list></property></bean><beanid="baseDao"class="com.tit.dao.impl.BaseDao"><propertyname="sessionFactory"ref="sessionFactory"></property></bean>
解决方案五:
这是我写的applicationContext.xml
解决方案六:
错误提示你userInfoDao没有自动创建bean,你是用的注解还是写在配置文件里的,配置文件没看到啊
解决方案七:
web.xml的配置信息贴出来
解决方案八:
你用到注解了没?你的sessionFactory的类错了。<beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
改为:class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
试试
解决方案九:
用的注解,后来不行,现在有写成bean了
解决方案十:
<?xmlversion="1.0"encoding="UTF-8"?><web-appversion="2.5"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><!--指定spring的配置文件,默认从web根目录寻找配置文件,我们可以通过spring提供的classpath:前缀指定从类路径下寻找--><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><!--对Spring容器进行实例化--><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!--struts2框架启动配置代码--><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class><init-param><param-name>config</param-name><param-value>struts.xml</param-value></init-param></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>这是web.xml
解决方案十一:
那个问题改回applicationContext.xml中的bean就不是这个错误了是下面这错误com.opensymphony.xwork2.inject.DependencyException:com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException:Nomappingfoundfordependency[type=com.opensymphony.xwork2.util.reflection.ReflectionProvider,name='default']inpublicvoidcom.opensymphony.xwork2.ObjectFactory.setReflectionProvider(com.opensymphony.xwork2.util.reflection.ReflectionProvider).atcom.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:144)atcom.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:113)atcom.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:90)atcom.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:86)atcom.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:86)atcom.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:71)atcom.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:67)atcom.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150)atjava.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)atjava.util.concurrent.FutureTask.run(FutureTask.java:138)atcom.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76)。。。。Causedby:com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException:Nomappingfoundfordependency[type=com.opensymphony.xwork2.util.reflection.ReflectionProvider,name='default']inpublicvoidcom.opensymphony.xwork2.ObjectFactory.setReflectionProvider(com.opensymphony.xwork2.util.reflection.ReflectionProvider).atcom.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:235)atcom.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:225)atcom.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.<init>(ContainerImpl.java:287)atcom.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:117)atcom.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:114)atcom.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:141)...46more
解决方案十二:
如果要用注解。。你把你的那个配置信息改为:我上面说的试试。。你的sessionFactory对应的类错了。。你试试