我正在尝试与 AOP 取得联系。因此我写了一个小helloworld,但它没有按我想要的方式工作。
在方面内,我使用关键字“after”,但是如果调用给定的方法,则“aspect” - 方法在连接点之前执行!?有人知道为什么吗?
其他一切都很好! (无一异常(exception)!)
<bean id="myAspectBean" class="hello.world.MyAspect">
</bean>
<bean id="helloBean" class="hello.world.Hello">
<property name="first" value="Hello"/>
<property name="second" value="World!"/>
</bean>
<aop:config>
<aop:aspect ref="myAspectBean">
<aop:pointcut id="pc" expression="execution(* sayHello(..))"/>
<aop:after pointcut-ref="pc" method="doit" />
</aop:aspect>
</aop:config>
最佳答案
我只是没有调试..
输出被缓冲,因此文本出现在“Hello world!”之前,但该方法在之后调用。
关于java - 即使使用关键字 "after",AOP 方面也会在给定方法之前执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12742409/