码迷,mamicode.com
首页 > 编程语言 > 详细

关于Spring使用XML配置AOP时pointcut位置的一个小问题

时间:2020-05-21 23:43:02      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:位置   span   ring   before   color   eth   after   使用   配置   

 <aop:config>
        <aop:pointcut id="xmllog" expression="execution(* com.xhu.service.MyService.*(..))"/>
        <aop:pointcut id="xmlafter" expression="execution(* com.xhu.service.MyService.testAfterXML(..))"/>
        <aop:aspect id="aspectxml2" ref="aopxml2">

            <aop:before method="LogBeforeXML" pointcut-ref="xmllog"/>
            <aop:after method="LogAfterXML" pointcut-ref="xmlafter"></aop:after>

        </aop:aspect>
    </aop:config>

问题描述:今天学习spring中使用XML配置AOP时遇到了点问题,配置多个切入点POINTCUT时,发现只能配置一个。

查阅资料才发现POINTCUT在XML文件中配置的位置有问题。

要配置多个point时格式如(标签pointcut在标签aspect之外):

 <aop:config>
        <aop:pointcut />
        <aop:pointcut />

<aop:aspect> </aop:aspect> </aop:config>

当pointcut标签在aspect标签中时,只能配置一个pointcut,第二个会失效。格式如:

 <aop:config>
        <aop:aspect>
<aop:pointcut/> </aop:aspect> </aop:config>

 

关于Spring使用XML配置AOP时pointcut位置的一个小问题

标签:位置   span   ring   before   color   eth   after   使用   配置   

原文地址:https://www.cnblogs.com/Unlimited-Rain/p/12934045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!