为啥我的前置通知出现了好几次的?

来源:6-2 ProxyFactoryBean及相关内容(上)

慕粉18755117234

2020-04-23 16:34

<bean id="testBeforeAdvice" class="com.spirng.java.aop.service.api.TestBeforeAdvice"></bean>
<bean id="testAfterReturningAdvice" class="com.spirng.java.aop.service.api.TestAfterReturningAdvice"></bean>
<bean id="testThrowAdvice" class="com.spirng.java.aop.service.api.TestThrowAdvice"></bean>
<bean id="testMethodInterceptor" class="com.spirng.java.aop.service.api.TestMethodInterceptor"></bean>

<bean id="logServiceImplTarget" class="com.spirng.java.aop.service.api.impl.LogServiceImpl"></bean>

<bean id="pointcutBean" class="org.springframework.aop.support.NameMatchMethodPointcut">
    <property name="mappedNames">
        <list>
            <value>ad*</value>
        </list>
    </property>
</bean>

<bean id="defaultAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
    <property name="advice" ref="testBeforeAdvice"></property>
    <property name="pointcut" ref="pointcutBean"></property>
</bean>

<bean id="logServiceImpl" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target" ref="logServiceImplTarget"></property>
    <property name="interceptorNames" >
        <list>
            <value>testBeforeAdvice</value>
            <value>testAfterReturningAdvice</value>
            <value>testThrowAdvice</value>
            <value>testMethodInterceptor</value>
        </list>
    </property>
</bean>

TestBeforeAdvice:com.sun.proxy.$Proxy14  add
TestBeforeAdvice:com.sun.proxy.$Proxy11  add
TestMethodInterceptor1:java.lang.reflect.Method add
TestBeforeAdvice:com.spirng.java.aop.service.api.impl.LogServiceImpl  add
LogServiceImpl>>>>>>>>>>000000000
TestMethodInterceptor2:null
TestAfterReturningAdvice:com.sun.proxy.$Proxy11  add  null


写回答 关注

0回答

还没有人回答问题,可以看看其他问题

Spring入门篇

为您带来IOC和AOP的基本概念及用法,为后续高级课程学习打下基础

268784 学习 · 963 问题

查看课程

相似问题