Spring使用tx标签配置的拦截器

<? 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:context ="http://www.springframework.org/schema/context"
    xmlns:aop ="http://www.springframework.org/schema/aop"
    xmlns:tx ="http://www.springframework.org/schema/tx"
    xsi:schemaLocation ="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" >

     < context:annotation-config  />
     < context:component-scan  base-package ="com.bluesky"   />

    

     <!--  定义事务管理器(声明式的事务)  -->   
     < bean  id ="transactionManager" class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
         < property  name ="sessionFactory"  ref ="sessionFactory"   />
     </ bean >


  <!--  结合AOP实现事务的织入 -->   
  <!--  配合事务通知 -->   
     < tx:advice  id ="txAdvice"  transaction-manager ="transactionManager" >
  <!-- 给方法配置事务,默认使用propagation-->   
         < tx:attributes >
             < tx:method  name ="add"  propagation ="REQUIRED"   />
         </ tx:attributes >
     </ tx:advice >
    

<!--配置事务切入-->   
     < aop:config >
         < aop:pointcut  id ="txPointCut" expression ="execution(* com.kangdamu.mapper.*.*(..))"/>
         < aop:advisor  advice-ref ="txAdvice" pointcut-ref ="txPointCut"/>         
     </ aop:config >       
</ beans >
posted @   micer  阅读(149)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
点击右上角即可分享
微信分享提示