Java Spring Error : Bean property '*****' is not writable or has an invalid setter method.

本文讨论了Spring框架中命名规则导致的错误及解决方法,重点在于Bean实例的属性名与配置文件中bean的属性引用保持一致的重要性。

项目调试出现这样的错误。检查发现原因是Spring 的命名规则惹的祸。

解决方法:下面2点的命名必须一致(除get和set方法第一个字母要大写。)

1,

protected IUserDAO iuserdao;

public IUserDAO getIuserdao() {
    return iuserdao;
}
public void setIuserdao(IUserDAO iuserdao) {
    this.iuserdao = iuserdao;
}

2,

    <bean id="userServiceImpl" class="com.app.user.service.impl.UserServiceImpl">
      <property name="iuserdao" ref="userDAOImpl"/>
    </bean>

 

关于为什么要符合这样的命名规则,估计涉及到spring的源代码的设计。

转载于:https://www.cnblogs.com/haimingwey/archive/2012/05/30/2526690.html

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;httpInvokerConfig&#39;: Unsatisfied dependency expressed through field &#39;appMerchantService&#39;; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;appMerchantDec&#39; defined in ServletContext resource [/WEB-INF/tpaic-auto-net-servlet.xml]: Cannot resolve reference to bean &#39;dispatchService&#39; while setting bean property &#39;dispatch&#39;; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;dispatchService&#39; defined in ServletContext resource [/WEB-INF/tpaic-auto-net-servlet.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;com.tpaic.nonmotor.biz&#39; defined in class path resource [com/tpaic/nonmotor/biz/beanRefContext.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;brandAutoTypeService&#39; defined in class path resource [com/tpaic/nonmotor/biz/brand-service-context.xml]: Cannot resolve reference to bean &#39;contractBoSupport&#39; while setting bean property &#39;contractBoSupport&#39;; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;contractBoSupport&#39; defined in class path resource [com/tpaic/nonmotor/biz/service-bo.xml]: Cannot resolve reference to bean &#39;inquireDetailService&#39; while setting bean property &#39;inquireDetailService&#39;; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;inquireDetailService&#39; defined in class path resource [com/tpaic/nonmotor/biz/service-context-part.xml]: Cannot resolve reference to bean &#39;inquireDetailBoService&#39; while setting bean property &#39;inquireDetailBoService&#39;; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;inquireDetailBoService&#39; defined in class path resource [com/tpaic/nonmotor/biz/service-bo.xml]: Cannot resolve reference to bean &#39;applyPolicyBo&#39; while setting bean property &#39;applyPolicyBo&#39;; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;applyPolicyBo&#39; defined in class path resource [com/tpaic/nonmotor/biz/service-bo.xml]: Cannot resolve reference to bean &#39;commonParameterSupport&#39; while setting bean property &#39;common&#39;; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;commonParameterSupport&#39; defined in class path resource [com/tpaic/nonmotor/biz/service-context-part.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property &#39;aggregatedSearchService&#39; of bean class [com.tpaic.nonmotor.biz.util.CommonParameterSupport]: Bean property &#39;aggregatedSearchService&#39; is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值