---
title: "spring事务配置实例<1>"
author: "prodream"
date: "2010-03-30T15:51:41Z"
tags: []
categories: ["企业架构"]
slug: "spring-1"
draft: false
lastmod: "2010-03-30T15:51:41Z"
id: 628293
url: "https://prodream.iteye.com/blog/628293"
---

&lt;bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;  
  &lt;property name="dataSource" ref="dataSource" /&gt;  
 &lt;/bean&gt;  
   
 &lt;aop:config proxy-target-class="true"&gt;  
  &lt;aop:pointcut id="transactionOperation"  
   expression="execution(* com.oa..\*Facade.\*(..))" /&gt;  
  &lt;aop:advisor advice-ref="txAdvice" pointcut-ref="transactionOperation" order="1"/&gt;  
 &lt;/aop:config&gt;  
   
 &lt;tx:advice id="txAdvice" transaction-manager="txManager"&gt;  
  &lt;tx:attributes&gt;  
   &lt;tx:method name="update\*" propagation="REQUIRED" rollback-for="Throwable"/&gt;  
   &lt;tx:method name="insert\*" propagation="REQUIRED" rollback-for="Throwable"/&gt;  
   &lt;tx:method name="delete\*" propagation="REQUIRED" rollback-for="Throwable"/&gt;  
   &lt;tx:method name="save\*" propagation="REQUIRED" rollback-for="Throwable"/&gt;  
   &lt;!-- other methods use the default transaction settings (see below) --&gt;  
   &lt;tx:method name="\*" read-only="true" /&gt;  
  &lt;/tx:attributes&gt;  
 &lt;/tx:advice&gt;  
   
 &lt;tx:annotation-driven transaction-manager="txManager" order="0"/&gt;  
 &lt;!-- 启用基于@AspectJ切面的驱动器 --&gt;  
 &lt;aop:aspectj-autoproxy/&gt;