Spring_Mybatis_事务处理
作者:互联网
Transation 事务开发
我们需要在beans.xml配置文件下导入tx标签,aop标签
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
面向切面配置 AOP
<!-- 配置事务 ================================================================================================--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <constructor-arg ref="dataSource"/> </bean> <tx:advice id="txadvice" transaction-manager="transactionManager"> <!-- 给哪些方法配事务--> <tx:attributes> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="txPointcut" expression="execution(* com.zhang.Mapper.*.*(..))"/> <aop:advisor advice-ref="txadvice" pointcut-ref="txPointcut"/> </aop:config>
标签:xml,tx,配置文件,Spring,事务处理,标签,Mybatis 来源: https://www.cnblogs.com/Sum-muji/p/15143095.html