首页 > 代码库 > Bean property 'xxx' is not writable or has an invalid setter method

Bean property 'xxx' is not writable or has an invalid setter method

出现此问题的原因是在ApplicationContext.xml中配置有问题,里面的bean的属性名称用 与 注入的类名称不一致

applicationContext.xml

<bean id="testdao" class="com.tre.daoImpl.UserDaoImpl">
</bean>
<bean id="testservice" class="com.tre.serviceImpl.UserServiceImpl">
<property name="userdao" ref="testdao"></property>
</bean>


userServiceImpl

private UserDao userdao;

public void setUserdao(UserDao userdao) {
this.userdao = userdao;
}

红色部分名称要一致。


Bean property 'xxx' is not writable or has an invalid setter method