zoukankan      html  css  js  c++  java
  • 【Spring】JDBC事务管理XML配置

    将spring事务管理与spirng-mybatis分离开了:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
         http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
         http://www.springframework.org/schema/tx 
         http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
         http://www.springframework.org/schema/aop 
         http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-4.0.xsd">
        <!-- 事务管理器  -->
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <!-- 在spring-mybatis中配置 -->
            <property name="dataSource" ref="dataSource"/>
        </bean>
        
        <!-- 事务策略txAdvice -->
        <tx:advice id="txAdvice" transaction-manager="transactionManager">
            <tx:attributes>
                <tx:method name="insert*" propagation="REQUIRED"/>
                <tx:method name="save*" propagation="REQUIRED"/>
                <tx:method name="delete*" propagation="REQUIRED"/>
                <tx:method name="update*" propagation="REQUIRED"/>
                <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
                <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
                <tx:method name="select*" propagation="SUPPORTS" read-only="true"/>
            </tx:attributes>
        </tx:advice>
        <!-- 通过切面执行事务管理 -->
        <aop:config>
            <!-- 指明了引用的事务策略:txAdvice,以及切入点 -->
            <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.z.service.impl.*.*(..))"/>
        </aop:config>
    </beans>
  • 相关阅读:
    C#中有关string和byte[]转换的问题
    慎用HyperThreading Technology
    MSN不能登录 解决“0x81000370错误”
    Life Is a Gamble
    Application Wizard生成的项目文件简介
    在Word中如何进行半行输入
    几个有用的短语
    C#学习之接口
    C++中不容易记忆的访问属性问题
    进一步理解VC中的句柄
  • 原文地址:https://www.cnblogs.com/zhengwenqiang/p/6804680.html
Copyright © 2011-2022 走看看