org.springframework.beans.factory.BeanCreationException:在类路径资源中创建名称为XXX的bean时出错

拉胡尔·雷(Rahul ray)

我不是在写setter getter并使用autowire,而是得到以下错误-

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aS400Statusfacade' defined in class path resource [CXF-Bean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'aS400StatusDAO' of bean class [com.metlife.mymet.admin.facade.AS400Statusfacade]: Bean property 'aS400StatusDAO' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(AccessController.java:250)
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.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

我的Spring-conf.xml

<bean id="aS400Statusfacade"
    class="com.metlife.mymet.admin.facade.AS400Statusfacade">
    <property name="aS400StatusDAO" ref="aS400StatusDAO"></property>
</bean>

我的自动接线课程-

public class AS400Statusfacade {
    Logger logger=Logger.getLogger(AS400Statusfacade.class);
    @Autowired
    AS400StatusDAO aS400StatusDAO=null;

    public String getAS400StatusInformation() {
        return aS400StatusDAO.getAS400Status();
    }
}
戴夫G

我认为您遇到的问题是,没有设置器和显式标记Spring不会知道您要从中获得什么。

尝试删除显式属性元素。

这将允许@Autowired批注尝试解析该值。

为了进一步说明这一点:

spring-conf.xml

<bean id="aS400Statusfacade"
    class="com.metlife.mymet.admin.facade.AS400Statusfacade">
    <!--
        The following property tag is not necessary. Spring's
        @Autowired and associated bean post-processor, will introspect
        and set the property with an appropriate candidate bean.
        Bean property setter, is not required for the post-processor
        to access/set the property.
    -->
    <!--
    <property name="aS400StatusDAO" ref="aS400StatusDAO"></property>
    -->
</bean>

AS400Statusfacade插图

public class AS400Statusfacade {
    Logger logger=Logger.getLogger(AS400Statusfacade.class);
    @Autowired
    AS400StatusDAO aS400StatusDAO=null;

    public String getAS400StatusInformation() {
        return aS400StatusDAO.getAS400Status();
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档