Invalid property 'transactionManager' of bean class的解决办法
2014-06-19 17:22
936 查看
<?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.0.xsd"> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"></property>
<property name="transactionAttributes">
<props>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<bean id="userDAO" class="dgut.ke.dao.impl.UserDAO">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="userService" parent="txProxyTemplate" class="dgut.ke.service.impl.UserService">
<property name="userDAO" ref="userDAO" />
</bean>
... ....
启动Tomecat时出了错.之前没有添加事务处理时.上面的代码是可以正常运行的.添加事务之后却出现以下错误
ERROR - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'transactionManager' of bean class [dgut.ke.service.impl.UserService]: 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?
Caused by:
org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManager' of bean class [dgut.ke.service.impl.UserService]: 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 id="userService" parent="txProxyTemplate" class="dgut.ke.service.impl.UserService">
<property name="userDAO" ref="userDAO" />
</bean>
换成以下代码就可以正常运行了
<bean id="userService" parent="txProxyTemplate">
<property name="target">
<bean class="dgut.ke.service.impl.UserService">
<property name="userDAO" ref="userDAO"></property>
</bean>
</property>
</bean>
文章出自:http://zhengweisincere.blog.163.com/blog/static/49844649201171012515667
<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.0.xsd"> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"></property>
<property name="transactionAttributes">
<props>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<bean id="userDAO" class="dgut.ke.dao.impl.UserDAO">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="userService" parent="txProxyTemplate" class="dgut.ke.service.impl.UserService">
<property name="userDAO" ref="userDAO" />
</bean>
... ....
启动Tomecat时出了错.之前没有添加事务处理时.上面的代码是可以正常运行的.添加事务之后却出现以下错误
ERROR - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'transactionManager' of bean class [dgut.ke.service.impl.UserService]: 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?
Caused by:
org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManager' of bean class [dgut.ke.service.impl.UserService]: 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 id="userService" parent="txProxyTemplate" class="dgut.ke.service.impl.UserService">
<property name="userDAO" ref="userDAO" />
</bean>
换成以下代码就可以正常运行了
<bean id="userService" parent="txProxyTemplate">
<property name="target">
<bean class="dgut.ke.service.impl.UserService">
<property name="userDAO" ref="userDAO"></property>
</bean>
</property>
</bean>
文章出自:http://zhengweisincere.blog.163.com/blog/static/49844649201171012515667
相关文章推荐
- Invalid property 'transactionManager' of bean class的解决办法
- Invalid property 'initialSize' of bean class 问题解决
- org.springframework.beans.InvalidPropertyException: Invalid property 'htd' of bean class [com.dao.im
- Invalid property 'annotatedClasses' of bean class
- Invalid property 'driver_class' of bean class
- 四、Invalid property 'dataSource' of bean class [xxx.dao.JdbcUserDao]: Bean property
- tomcat启动报错:Invalid property 'userService' of bean class [xxxx]: No property 'xxx' found
- Invalid property 'url' of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]
- creating bean with name 'dataSource' defined in class path resource错误的解决办法
- Spring配置文件加载时出现Bean property 'newscontentDAO' is not writable or has an invalid setter method错误的解决
- Invalid property 'name' of bean class
- Uncaught TypeError: Cannot read property 'drawImage' of undefined错误的解决办法
- Invalid property 'annotatedClasses' of bean class
- NodeJs Cannot read property 'Store' of undefined 解决办法
- Mybatis 对单独传入参数string进行判断时报There is no getter for property named '**' in 'class java.lang.String解决办法
- Ibatis中的一个“There is no READABLE property named 'uId' in class 'useri 的解决办法
- Spring配置文件加载时出现Bean property 'newscontentDAO' is not writable or has an invalid setter method错误的解决[00原创]
- invalid use of incomplete type 'class-Ui-Widge't的解决办法
- ProbeException解决办法:There is no WRITEABLE property named 'id' in class 'java.lang.String'
- 基于QWidget类的动态库在4.8.1隐式调用时出现staticMetaObject' of dllimport'd class的解决办法