gpt4 book ai didi

java - @After 的 AOP 切入点

转载 作者:行者123 更新时间:2023-11-30 06:49:36 27 4
gpt4 key购买 nike

我想要 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());
}

关于java - @After 的 AOP 切入点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43083379/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com