Java 当@Around用于Spring AOP时,则不会检索数据

Java 当@Around用于Spring AOP时,则不会检索数据,java,spring,spring-boot,spring-aop,spring-restcontroller,Java,Spring,Spring Boot,Spring Aop,Spring Restcontroller,我是spring AOP,我有下面的@Around @Around(value = "execution(* com.spring.rest.controller.Controller.*(..))") public void around(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); joinPoint.proceed(); long

我是spring AOP,我有下面的@Around

@Around(value = "execution(* com.spring.rest.controller.Controller.*(..))")
public void around(ProceedingJoinPoint joinPoint) throws Throwable {
    long start = System.currentTimeMillis();
    joinPoint.proceed();
    long taken = System.currentTimeMillis() - start;
    logger.info("around this {} time taken is {}", joinPoint, taken);
} 
在我的Rest控制器中,我有getmapping,当我在浏览器中调用该路由时,没有检索到任何数据

从日志中,我发现它返回null(在日志信息下面)-- @执行Around时需要20秒,@AfterReturning在返回null时执行

2020-05-07 00:41:03.083  INFO 366372 --- [nio-8080-exec-1] lication$$EnhancerBySpringCGLIB$$21c1be2 : around this execution(List com.spring.rest.controller.Controller.getm()) time taken is 20
2020-05-07 00:41:03.084  INFO 366372 --- [nio-8080-exec-1] lication$$EnhancerBySpringCGLIB$$21c1be2 : returning execution(List com.spring.rest.controller.Controller.getm()) returned with value null
但是当我删除@Around时,API工作得非常好


我可以知道原因是什么以及如何解决此问题吗?

您需要返回对象

public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
    long start = System.currentTimeMillis();
    Object object = joinPoint.proceed();
    long taken = System.currentTimeMillis() - start;
    logger.info("around this {} time taken is {}", joinPoint, taken);
    return object;
} 

您需要返回对象

public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
    long start = System.currentTimeMillis();
    Object object = joinPoint.proceed();
    long taken = System.currentTimeMillis() - start;
    logger.info("around this {} time taken is {}", joinPoint, taken);
    return object;
}