java - 即使使用关键字 "after",AOP 方面也会在给定方法之前执行?

标签 java spring aop aspect

我正在尝试与 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/

相关文章:

java - AS400 作业线程详细信息

java - 关键部分: be sure that this method is executed by only 1 thread

java - Spring JPA - 更新多个字段的最佳方式

java - 根据相应的输入 channel 适当存储通知

Spring AOP : What's the difference between JoinPoint and PointCut?

java - windows批处理中如何从程序跳转到退出

java - Spring Boot 不会替换 Spring Tool Suite 版本 : 3. 8.4.RELEASE 中的系统变量 {user.home}

java - 从数据库表生成 java 域对象

c# - 有没有办法从属性测量 C# 函数执行时间?

java - Eclipse Java 语法着色并不完全适用于 SVN 的 check out 代码