【问题标题】:AOP pointcut for @After [duplicate]@After的AOP切入点[重复]
【发布时间】:2017-03-29 02:46:11
【问题描述】:

我想要 AOP 记录方法的返回值

    @After("execution(* com.dbs.tup.sample.service.*.*(..))")
    public void logAfter(JoinPoint point) {
        log.info("{} is returning {}", point.getSignature().getName(), "???");
    }

【问题讨论】:

    标签: java casting return-value spring-aop pointcut


    【解决方案1】:

    我找到了这个

        @AfterReturning(pointcut = "execution(* com.dbs.tup.sample.service.*.*(..))", returning = "retValue")
        public void logAfter(JoinPoint point, Object retValue) {
            log.info("{} is returning {}", point.getSignature().getName(), (((MethodSignature) point.getSignature()).getReturnType().cast(retValue)).toString());
        }
    

    【讨论】:

    • 提示:您可以接受自己的答案以结束问题。 :-)
    猜你喜欢
    • 2020-01-30
    • 1970-01-01
    • 2020-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多