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>
  • 相关阅读:
    Linux_CentOS_6.5安装Nginx
    数据恢复
    Kali Linux渗透测试第二步:漏洞评估
    Django 中的urls 导入
    python django url导入
    SpringMVC之组合注解@GetMapping
    Spring中@Controller和@RestController之间的区别
    Spring中@Autowired注解、@Resource注解的区别
    如何把字符串数组从 Swift 传递给 C
    如何把字符串数组从 Swift 传递给 C
  • 原文地址:https://www.cnblogs.com/zhengwenqiang/p/6804680.html
Copyright © 2011-2022 走看看