解决Spring AOP 事务 配置 失效原因

采用AOP配置声明式事务有5种方式,下面只说关于采用TransactionInterceptor事务拦截器的方式,配置程序如下:

transactionManager的:

XML代码  收藏代码
  1.  的id “dataSource的”  “org.apache.commons.dbcp.BasicDataSource”  破坏法“关闭”  />   
  2.   
  3. bean  id "transactionManager"  class "org.springframework.jdbc.datasource.DataSourceTransactionManager" >   
  4.     属性 “dataSource的”  参考“的dataSource”  />  
  5. </ >  

  

 的TransactionInterceptor:

 

XML代码  收藏代码
  1. bean  id "transactionInterceptor"  class "org.springframework.transaction.interceptor.TransactionInterceptor" >  
  2.     属性 “transactionManager的”  REF “transactionManager的”  />   
  3.     属性 “transactionAttributes” >   
  4.     道具>   
  5.          “添加*” PROPAGATION_REQUIRED </ 道具>   
  6.          “德尔*” PROPAGATION_REQUIRED </ 道具>  
  7.          “更新*” PROPAGATION_REQUIRED </ 道具>   
  8.          “查询*” 只读</ 道具>   
  9.          “得到*” 只读</ 道具>   
  10.          “找到*” 只读</ 道具>   
  11.          “检查*” PROPAGATION_REQUIRED </ 道具>   
  12.          “操作*” PROPAGATION_REQUIRED </ 道具>   
  13.          “批量*” PROPAGATION_REQUIRED </ 道具>   
  14.          “部署*” PROPAGATION_REQUIRED </ 道具>   
  15.          “EXEC *” PROPAGATION_REQUIRED </ 道具>   
  16.     </ 道具>   
  17.     </ 财产>   
  18. </ >   

   

自动代理的BeanNameAutoProxyCreator:

XML代码  收藏代码
  1. bean的 “org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator” >   
  2.     属性 “beanNames” >   
  3.         < - !所有以BUSImpl命名的豆-ID都会被事务拦截 - >   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值