zoukankan      html  css  js  c++  java
  • Spring转账业务_XML配置事物控制

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <beans xmlns="http://www.springframework.org/schema/beans" 
     3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4      xmlns:context="http://www.springframework.org/schema/context"
     5      xmlns:aop="http://www.springframework.org/schema/aop" 
     6     xmlns:tx="http://www.springframework.org/schema/tx"  
     7     xsi:schemaLocation="
     8         http://www.springframework.org/schema/beans 
     9         http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    10         http://www.springframework.org/schema/context 
    11         http://www.springframework.org/schema/context/spring-context-3.2.xsd 
    12         http://www.springframework.org/schema/aop 
    13         http://www.springframework.org/schema/aop/spring-aop.xsd
    14         http://www.springframework.org/schema/tx 
    15         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    16         
    17     <!-- 扫描包基础目录 -->
    18     <context:component-scan base-package="com.wisezone"></context:component-scan>
    19     
    20     <!-- 加载properties 配置文件 -->
    21     <context:property-placeholder location="db.properties"/>
    22     
    23     <!-- c3p0数据源配置 -->
    24     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    25         <property name="driverClass" value="${driver}"></property>
    26         <property name="jdbcUrl" value="${url}"></property>
    27         <property name="user" value="${user}"></property>
    28         <property name="password" value="${password}"></property>
    29     </bean>
    30     
    31     <!-- jdbc模板类配置 -->
    32     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    33         <!-- 属性名称固定 -->
    34         <property name="dataSource" ref="dataSource"></property> 
    35     </bean>
    36     
    37     <aop:aspectj-autoproxy/>
    38     
    39     <!-- 事物管理器配置 -->
    40     <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    41         <property name="dataSource" ref="dataSource"></property>
    42     </bean>
    43     
    44     <!-- 配置事物通知 -->
    45     <tx:advice id="txAdvice" transaction-manager="txManager">
    46         <tx:attributes>
    47             <tx:method name="save*" propagation="REQUIRED"/>
    48             <tx:method name="update*" propagation="REQUIRED"/>
    49             <tx:method name="del*" propagation="REQUIRED"/>
    50         </tx:attributes>
    51     </tx:advice>
    52     
    53     <!-- 切面配置 -->
    54     <aop:config>
    55         <!-- ..:表示service下所有子包    (..):表示拦截的东西 -->
    56         <aop:pointcut expression="execution (* com.wisezone.service..*.*(..))" id="cut"/>
    57         <aop:advisor advice-ref="txAdvice" pointcut-ref="cut"/>
    58     </aop:config>
    59 </beans>
  • 相关阅读:
    rzchecktree用作类别权限的问题
    VirtualStringTree 动态建树/Checktree
    一键处理打印机因任务不能取消,无法接着打印
    Delphi从Internet下载文件
    仿迅雷客户端的浏览器自定义协议的小程序
    用最少的代码为你的窗体实现剪贴板操作
    delphi2010获取鼠标指向窗口的位置及鼠标在窗口内的相对位置坐标
    datasnap 上传/下载大文件(本Demo以图传片文件为例)
    dephi中用idhttp提交cookie
    delphi2010 向另一个窗口发送鼠标点击事件
  • 原文地址:https://www.cnblogs.com/wdh1995/p/6792175.html
Copyright © 2011-2022 走看看