同类型的aop:aspect谁先执行

spring对于同类型aspect谁先执行是不确定的,但是可以通过order属性设置数值,数值小的会优先执行

<aop:config>
        <aop:pointcut id="studentPointcut" expression="execution(* com.target.StudentDaoImpl.*(..))"/>
         <!--第一个-->
        <aop:aspect ref="log" order="2">
            <aop:around method="aroundInsert" pointcut-ref="studentPointcut"/>
        </aop:aspect>
         <!--第二个-->
        <aop:aspect ref="log" order="4">
            <aop:around method="aroundInsert2" pointcut-ref="studentPointcut"/>
        </aop:aspect>
</aop:config>

proxy-target-class

得到实现类,调用实现类的方法,而不是接口,调用接口的方法,需要使用cglib代理创建aop代理对象,在aop:config中的属性 proxy-target-class设置为true即可。

<aop:config proxy-target-class="true">
</aop:config>

 

posted @ 2019-11-03 21:03  过期可乐  阅读(163)  评论(0编辑  收藏  举报