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 @ 2021-10-18 22:04  micer  阅读(152)  评论(0)    收藏  举报