日期:2014-05-17  浏览次数:20675 次

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=