Bean property 'userService' is not writable or has an invalid setter method. Doe

Bean property userService is not writable or has an invalid setter method. Doe用spring注入的时候

Bean property 'userService' is not writable or has an invalid setter method. Doe
用spring注入的时候出现这种错误,在网上查了好多都是因为命名不规范导致的spring注入错误,但是我感觉我这没错啊,以前也这么写过都没错。

我而且我给userService都换名了还是不行啊。。。

求助!


spring配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">


<!-- ########### SessionFactory ################ -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml">
</property>
</bean>

<!-- ########### HibernateTemplate ################ -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- ########### Dao和Service ################ -->
<bean id="baseDao" abstract="true">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>

<bean id="userDao" class="com.zhangss.stumanager.dao.impl.UserDaoImpl"
parent="baseDao">
</bean>

<bean id="studentDao" class="com.zhangss.stumanager.dao.impl.StudentDaoImpl"
parent="baseDao">
</bean>

<bean id="userService" class="com.zhangss.stumanager.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>

<bean id="studentService" class="com.zhangss.stumanager.service.impl.StudentServiceImpl">
<property name="studentDao" ref="studentDao"></property>
</bean>
<!-- ###########事务AOP################ -->
<!--
transactionManager tx:advice - 在什么方法上应用什么类型的事务 aop:config - 选择在哪些切入点切入
tx:adviser
-->
<bean id="txMgr"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<tx:advice id="txAdvice" transaction-manager="txMgr">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>

<aop:config>
<aop:pointcut id="allService"
expression="execution(* com.liuyake.netctoss.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allService" />
</aop:config>


<!-- ########### Action 对象 ################ -->

<bean id="loginFormAction" class="com.zhangss.stumanager.action.LoginFormAction">
</bean>

<bean id="loginAction" class="com.zhangss.stumanager.action.LoginFormAction" scope="prototype">
<property name="userService" ref="userService"></property>
<property name="studentService" ref="studentService"></property>
</bean>

</beans>



action中

package com.zhangss.stumanager.action;

import com.zhangss.stumanager.service.StudentService;
import com.zhangss.stumanager.service.UserService;

public class LoginAction {

private String userName;
private String password;
private UserService userService;
private StudentService studentService;


public String execute(){
if(userService.validateUser(userName, password)){
return "success";
}
return "fail";
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}


public UserService getUserService() {
return userService;
}

public void setUserService(UserService userService) {
this.userService = userService;
}

public StudentService getStudentService() {
return studentService;
}

public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}


}



[解决办法]
<bean id="loginAction" class="com.zhangss.stumanager.action.LoginFormAction" scope="prototype">
class写错了吧?应该是LoginAction