一、自动代理
二、利用<aop:config>
第三、 AspectJProxyFactory 、自动代理、<aop:config> 之间冲突只能用其一
<!--
自动代理方式一 -->
<!-- <aop:aspectj-autoproxy /> -->
<!-- 自动代理方式二 -->
<!-- <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"/>-->
<!-- <aop:aspectj-autoproxy /> -->
<!-- 自动代理方式二 -->
<!-- <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"/>-->
二、利用<aop:config>
<!--
<aop:config> 利用普通Bean实现切面 -->
< aop:config >
< aop:pointcut expression ="execution(* getContext(..) ) and within(cn.aop.aspect.service.*) and target(obj) and this(proxy) and args(str)" id ="before" />
< aop:aspect ref ="loggingBeforeAspectBean" >
< aop:before method ="beforeAspect" pointcut-ref ="before" />
</ aop:aspect >
< aop:aspect ref ="loggingAfterReturningAspectBean" >
< aop:after-returning method ="afterReturningAspect" pointcut-ref ="before" returning ="retur" />
</ aop:aspect >
< aop:aspect ref ="loggingAroundAspectBean" >
< aop:around method ="aroundAspect" pointcut-ref ="before" />
</ aop:aspect >
< aop:aspect ref ="loggingAfterThrowingBean" >
< aop:after-throwing method ="afterThrowingAspect" pointcut-ref ="before" throwing ="thro" />
</ aop:aspect >
< aop:aspect ref ="introduction" >
< aop:declare-parents types-matching =" cn.aop.aspect.service.*" implement-interface ="cn.aop.aspect.itf.IntroITF" default-impl ="cn.aop.aspect.itf.impl.IntroImpl" />
</ aop:aspect >
</ aop:config >
< aop:config >
< aop:pointcut expression ="execution(* getContext(..) ) and within(cn.aop.aspect.service.*) and target(obj) and this(proxy) and args(str)" id ="before" />
< aop:aspect ref ="loggingBeforeAspectBean" >
< aop:before method ="beforeAspect" pointcut-ref ="before" />
</ aop:aspect >
< aop:aspect ref ="loggingAfterReturningAspectBean" >
< aop:after-returning method ="afterReturningAspect" pointcut-ref ="before" returning ="retur" />
</ aop:aspect >
< aop:aspect ref ="loggingAroundAspectBean" >
< aop:around method ="aroundAspect" pointcut-ref ="before" />
</ aop:aspect >
< aop:aspect ref ="loggingAfterThrowingBean" >
< aop:after-throwing method ="afterThrowingAspect" pointcut-ref ="before" throwing ="thro" />
</ aop:aspect >
< aop:aspect ref ="introduction" >
< aop:declare-parents types-matching =" cn.aop.aspect.service.*" implement-interface ="cn.aop.aspect.itf.IntroITF" default-impl ="cn.aop.aspect.itf.impl.IntroImpl" />
</ aop:aspect >
</ aop:config >
第三、 AspectJProxyFactory 、自动代理、<aop:config> 之间冲突只能用其一
转载于:https://blog.51cto.com/wuql4689908/668720