日期:2014-05-19  浏览次数:20815 次

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 failed
org.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.instant

iateBean(AbstractAutowireCapableBeanFactory.java:883)
    at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createB

eanInstance(AbstractAutowireCapableBeanFactory.java:839)
    at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreat

eBean(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.createB

ean(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.preInstantiateS

ingletons(DefaultListableBeanFactory.java:429)
    at 

org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInit

ialization(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 
                         求解~为啥界面repaint后之前画的东西都不见了