当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Cannot Implement DataSourceTransactionManager bean in Spring

问题描述:

I am currently trying to set up my Spring to be able to run Transactions with the NameParameterJdbcTemplate but I keep getting a BeanCreationException. It seems to be tied to a NotWritablePropertyException with my txManager bean. Any idea on what I can do to fix this?

<bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">

<constructor-arg ref="dataSource"></constructor-arg>

<property name="txManager" ref="txManager"></property>

</bean>

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

<property name="dataSource" ref="dataSource"></property>

</bean>

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/aoa" resource-ref="true"/>

Error I keep getting

ERROR org.mortbay.log - Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'agencyDao' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Cannot resolve reference to bean 'namedParameterJdbcTemplate' while setting bean property 'namedParameterJdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'namedParameterJdbcTemplate' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'txManager' of bean class [org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate]: Bean property 'txManager' 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 'txManager' of bean class [org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate]: Bean property 'txManager' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

分享给朋友:
您可能感兴趣的文章:
随机阅读: