日期:2014-05-20  浏览次数:20738 次

spring中的配置问题?
我引用父类,但是报错。该怎么解决?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/userAdd' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManager' of bean class [com.yourcompany.struts.action.UserAddAction]: Bean property 'transactionManager' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManager' of bean class [com.yourcompany.struts.action.UserAddAction]: Bean property 'transactionManager' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

源码:
<bean name="userpro" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transaction" />
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>

</bean>

<bean name="userbo" class="bo.UserBo">
<property name="userdao">
<ref bean="SUserDAO" />
</property>
</bean>

<bean name="/userAdd" parent="userpro"
class="com.yourcompany.struts.action.UserAddAction">
<property name="udao">
<ref bean="userbo"/>
</property>
</bean>

------解决方案--------------------
struts的action不适应spring的类,你最好做个service,来继承你的parent,然后再在action中得到service.