如何使事务代理注入多个bean

来源:百度知道 编辑:UC知道 时间:2024/05/21 19:15:08
如何使事务代理注入多个bean?
<bean id="userDAOProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="myDAO" />
</property>
<property name="target">
<ref local="userDAO" /> </property>------我加了这属性后就报错了,userDAO已经定义了.

我想知道如何使多个bean共享同一个TransactionProxyFactoryBean

贴一个偶以前写的.

<!-- 配置事务拦截器Bean -->
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<!-- 为事务拦截器bean注入一个事物管理器 -->
<property name="transactionManager"
ref="hibernateTransactionManager" />
<property name="transactionAttributes">
<!-- 定义事务传播属性 -->
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="change*">PROPAGATION_R