Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'weDAO' of bean class [com.service.WeManageServiceImpl]: Bean property 'weDAO' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
applicationContext-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 <bean id="TestAction" class="com.action.TestAction"  scope="prototype">
<property name="weManageService" ref="weManageService"> </property>
</bean>

<bean id="weManageService" class="com.service.WeManageServiceImpl">
     <property name="weDAO" ref="weDAO"></property>
</bean>
 
</beans>
struts:
weManageService.getAllBooks();WeManageService.java
package com.service;
import java.util.List;
import com.We;
public interface  WeManageService {
public List<We> getAllBooks();
    public List<We> getBookByName(String name);
    public void updateBook(We book);
}WeManageServiceImpl.java
package com.service;
import java.util.List;
import com.We;
import com.WeDAO;public class WeManageServiceImpl implements WeManageService{
    private WeDAO weDAO;    
    public List<We> getAllBooks(){
     System.out.println(">>>>>>>>>>>>>1dddd");
        return weDAO.findAll();
    }
 
    public List<We> getBookByName(String name) {
        return weDAO.findByMc(name);
    }    public void updateBook(We book) {
     weDAO.attachDirty(book);
    }
 
}

解决方案 »

  1.   

    weManageService要引用weDAO,必须把它俩放在同一文件中。
      

  2.   

    weDAO在配置文件中没有依赖注入,然后在WeManageServiceImpl中也没有getter,setter方法
      

  3.   

    com.action.TestAction中需要下面的代码.
    com.WeDAO weDAO = null;
    public void setWeDAO(com.WeDAO weDAO) {
      this.weDAO=weDAO;
    }
      

  4.   

    Invalid property 'weDAO' of bean class [com.service.WeManageServiceImpl]: Bean property 'weDAO' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?已经说的很清楚了。
    private WeDAO weDAO;
    这个变量需要get/set方法