主要的相关的代码
-------------dao--------------------
public class StudentDaoImpl extends HibernateDaoSupport implements StudentDao {
public void addStudent(Student student) {
this.getHibernateTemplate().save(student);
}
}
--------------service----------------------
public class StudentServiceImpl implements StudentService {
private StudentDao studentDao;
public void addStudent(Student student) {
studentDao.addStudent(student);
}
public void setStudentDao(StudentDao studentDao) {
this.studentDao = studentDao;
}
}
--------------xml------------------------
<bean id="studentDao" class="org.ujs.ssh.dao.impl.StudentDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="studentService" class="org.ujs.ssh.service.impl.StudentServiceImpl">
<property name="studentDao" ref="studentDao"/>
</bean> 
错误提示:
Invalid property 'studentService' of bean class [org.ujs.ssh.action.StudentActioin]: Bean property 'studentService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
拜托各位大大了,小生这厢有礼了

解决方案 »

  1.   

    查看你的org.ujs.ssh.action.StudentActioin类,
    检查其字段成员studentService类型是不是StudentService
    和有正确的getStudentService方法和setStudentService方法,
    及getStudentService的返回类型和setStudentService的参数类型。
      

  2.   

    还有类似下面的配置
    <bean id="studentActioin" class="org.ujs.ssh.action.StudentActioin">
    <property name="studentService" ref="studentService"/>
    </bean>
    正确与否
      

  3.   

    注入失败,Bean property 'studentService' is not writable or has an invalid setter method:翻译:Bean属性studentService没有定义,或者没有定义setter方法。总结,spring注入失败
      

  4.   

    哎呀,我只顾看dao和service包了,连错误说明都没看清,还是经验少啊