spring aop order

来源:互联网 发布:three.js 添加热点 编辑:程序博客网 时间:2024/05/18 04:01

自己写了一个aop

 

想被包含在 事务中,刚开始以为 order越小越先执行,发现不是,我这里用的around的,需要事务嵌套在外面。

实际是,order越小,越在外围

 

 <!-- order 的值越小,越在外围-->
 <tx:annotation-driven transaction-manager="txManager" order="1" />

 

<aop:config >
  <!-- 添加流程保存的切面方法 -->
   <aop:pointcut expression="execution(* *..*ServiceImpl.save(..))||execution(* *..SZ*ServiceImpl.save(..))" id="flowSavePoint"/>
   <!-- order 的值越小,越在外围-->
   <aop:aspect  ref="flowSaveAspect" order="2">
   <aop:around method="aroundMethod" pointcut-ref="flowSavePoint"/>
  </aop:aspect>
 </aop:config>

 <!-- 自动为spring容器中那些配置@aspectJ切面的bean创建代理,织入切面 -->
    <aop:aspectj-autoproxy />
 
    <!-- 使用annotation自动注入bean,并启动相关处理注解的进程 -->
 <context:component-scan base-package="com.xxxx">

 </context:component-scan>    

 

参考url:http://www.iteye.com/topic/1047080

 

0 0
原创粉丝点击