<!--声明式事物管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 事务通知 -->
<tx:advice id="txAdivce" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="find*" read-only="false"/>
<tx:method name="get*" read-only="false"/>
<tx:method name="view*" read-only="false"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.oa.service.*.*(..))" id="txPointcut"/>
<aop:advisor advice-ref="txAdivce" pointcut-ref="txPointcut"/>
</aop:config>
<!-- 配置基于注解的声明式事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
配置事务管理
最新推荐文章于 2024-08-26 23:50:02 发布
本文详细介绍了如何在Spring框架中使用XML配置实现声明式事务管理。通过DataSourceTransactionManager和tx:advice定义了对增删改查等操作的事务控制,确保数据的一致性和完整性。
782

被折叠的 条评论
为什么被折叠?



