spring-mybatis 事务

保证数据的一致性和完整性

官网:http://mybatis.org/spring/zh/transactions.html

声明式事务

spring中配置声明事务

    <!--配置声明事务-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <constructor-arg ref="dataSource" />
    </bean>

    <!--结合AOP实现事务的注入-->
    <!--配置事务的通知-->
    <tx:advice id="textAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <!--*代表所有-->
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>
    
    <!--配置事务切入-->
    <aop:config>
        <aop:pointcut id="txPoint" expression="execution(* com.wt.mapper.UserMapperImpl.*(..))"/>
        <aop:advisor advice-ref="textAdvice" pointcut-ref="txPoint"/>
    </aop:config>
原文地址:https://www.cnblogs.com/wt7018/p/13340502.html