@Around( AOP ) 的 joinPoint 继续但没有 return 结果

joinPoint of @Around( AOP ) proceeds but doesn't return result

我用@Around用springboot实现AOP。喜欢下面

@Around("cut()")
public void advice( ProceedingJoinPoint proceedingJoinPoint ) throws Throwable {
    System.out.println("@Around start");
    proceedingJoinPoint.proceed();
    System.out.println("@Around end");
}

joinPoint 是我的控制器 & "@Mylog" 是我下面的自定义 annotation.Like

@MyLog
@RequestMapping("/log")
public String getLog() throws InterruptedException {
    System.out.println("This is joinPoint");
    return "Hello World";
}

当我尝试使用浏览器获取路由“/log”时,信息按预期打印,但没有任何内容返回到浏览器(我预计 "Hello World" 将返回)。喜欢下面

@Around start
This is joinPoint
@Around end

有什么建议吗?

如果您的 around advice returns nothing (void) 而不是 proceed() 结果,那么您应该不会感到惊讶,那么实际上什么也不会返回。 ;-) 这个怎么样?

@Around("cut()")
public Object advice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    System.out.println("@Around start");
    try {
        return proceedingJoinPoint.proceed();
    }
    finally {
        System.out.println("@Around end");
    }
}