zoukankan      html  css  js  c++  java
  • 在Spring的核心配置文件applicationContext.xml中配置事务,主要配置三大方面:事务管理器、事务通知和定义事务性切面。

     在Spring的核心配置文件applicationContext.xml中配置事务,主要配置三大方面:事务管理器、事务通知和定义事务性切面。

    代码如下:

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
    <!-- 事务管理器 -->
    <bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <!-- 数据源 -->
    <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- 事务通知 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <!-- 传播行为 -->
    <tx:method name="save*" propagation="REQUIRED" />
    <tx:method name="insert*" propagation="REQUIRED" />
    <tx:method name="add*" propagation="REQUIRED" />
    <tx:method name="create*" 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="select*" propagation="SUPPORTS" read-only="true" />
    <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
    </tx:attributes>
    </tx:advice>
    <!-- 定义事务性切面 -->
    <aop:config>
    <aop:advisor advice-ref="txAdvice"
    pointcut="execution(* cn.e3mall.service..*.*(..))" />
    </aop:config>
    </beans>


  • 相关阅读:
    UICollectionView 应用
    关于UIWebView不能响应touchesBegan等四个方法的解决案例【可以检测 单击双击】
    IOS6 中新特性介绍
    KVO 使用
    IOS 学习资料汇总(^_^)
    [DEVDIV翻译] Core Animation中文翻译_第一章_什么是核心动画
    StoryBoard学习..(很详细.)
    Intent跳转到系统应用中的拨号界面、联系人界面、短信界面及其他
    sqlite语句主页
    Android的快速开发框架 afinal
  • 原文地址:https://www.cnblogs.com/yuwenweisan/p/11004113.html
Copyright © 2011-2022 走看看