@After 的 AOP 切入点

AOP pointcut for @After

我想要方法的 return 值的 AOP 日志记录

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

我找到了这个

    @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());
    }