spring 错误(org.springframework.beans.NotWritablePropertyException)

出了个错,看到下面这篇文章才解决的,感谢作者,转载一下:
 
原文地址 http://hi.baidu.com/%B9%C2%B6%C0%B5%C4%D1%B0%D5%D2%D7%C5/blog/item/c8dcc32de618c4e68a139987.html
 
org.springframework.beans.NotWritablePropertyException: Invalid property 'postDao' of bean class?

  出现异常的原因是在application-xxx.xml中property name的错误。

  <property name="...."> 中name的名字是与bean的set方法相关的,而且要注意大小写。

  比如

public class PostManageImpl extends BaseManage implements PostManage {
 private PostDAO dao = null;
 public void setPostDAO(PostDAO postDAO){
  this.dao = postDAO;
 }
}

  那么xml的定义应该是:

<bean id="postManage" parent="txProxyTemplate">
<property name="target">
 <bean class="com.yz.spring.service.implement.PostManageImpl">
  <property name="postDAO"><ref bean="postDAO"/></property> 对
  <property name="dao"><ref bean="postDAO"/></property> 错
 </bean>
</property>
</bean>

你可能感兴趣的:(spring,DI,异常,IOC,setter依赖)