当前位置: 代码迷 >> J2EE >> applicationXML无bean的定义?解决方法
  详细解决方案

applicationXML无bean的定义?解决方法

热度:104   发布时间:2016-04-22 01:47:33.0
applicationXML无bean的定义??
HTML code
<beans>    <!-- 登陆action -->    <bean id="userService" class="com.itadmin.service.UserService" />    <bean id="loginAction" class="com.itadmin.action.LoginAction">        <property name="userService">            <ref bean="userService"/>         </property>    </bean>           <!-- 注销action -->    <bean id="logoutAction" class="com.itadmin.action.LogoutAction">    </bean>     </beans>  

这是applicationContext.xml文件

报错如下:

Java code
8:19:29,262 ERROR org.springframework.web.context.ContextLoader:215 - Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginAction' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.itadmin.action.LoginAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService' is defined    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)    at java.security.AccessController.doPrivileged(Native Method)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
  相关解决方案