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

 

Bean property 'xxDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'xxDao' of bean class [com.xx.framework.exam.service.impl.xxServiceImpl]: Bean property 'xxDao' 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.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:793)

at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)

 

 

如上报错是由于 注入dao名和注入service名写错了,必须要保证程序中的getter setter方法中的命名和注入名一致

 

applicationContext.xml中的配置如下:...

<bean id="xxDao" class="com.xx.daoimp.xxDaoImp" scope="singleton">
  <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>
 <!--  把service交给Dao -->
 
  <bean id="xxService" class="com.xx.serviceimp.xxServiceImp">
  <property name="xxDao" ref="xxDao"></property>
 </bean>

 <bean id="xx" class="com.starheld.action.xxAction">
  <property name="xxservice" ref="xxService"></property>
 </bean>

<bean id="xx" class="com.xx.framework.exam.action.xxAction">
	    <property name="xxService">
		    <ref bean="xxService" />
	    </property>	
    </bean>
...

 代码如下:

 

public class xxAction extends ActionSupport {
private User sser ;
 private xxService xxservice;

 public xxService getxxservice() {
  return xxservice;
 }

 public void setxxservice(xxService xxservice) {
  this.xxservice = xxservice;
 }

 public User getUser() {
  return user;
 }

 public void setUser(User user) {
  this.user = user;
 }

public class xxServiceImp implements xxService {
 public xxDao xx;
 public boolean find(String username) {
  // 查找用户名是否存在
  return xx.find(username);
 }
 public void savexx(User user) {
  // 保存注册信息
  this.xx.SaveUser(user);
 }
 public xxDao getxx() {
  return xx;
 }
 public void setxx(xxDao xx) {
  this.xx = xx;
 }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值