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>

 

上一篇:docker启动报错[Warning] IPv4 forwarding is disabled. Networking will not work解决办法


下一篇:吴恩达机器学习(十三)—— 推荐系统