Java SpringAOP没有错误,但不执行通知

Java SpringAOP没有错误,但不执行通知,java,spring,spring-boot,spring-aop,Java,Spring,Spring Boot,Spring Aop,我是SpringAOP新手,通过下面的文章尝试了下面的代码 方面类: @Aspect @Component public class LoggingAspect { private final static Logger LOGGER = LoggerFactory.getLogger(LoggingAspect.class); @Around("@annotation(Debug)") public Object beforeDebug(ProceedingJoin

我是SpringAOP新手,通过下面的文章尝试了下面的代码

方面类:

@Aspect
@Component
public class LoggingAspect {

    private final static Logger LOGGER = LoggerFactory.getLogger(LoggingAspect.class);

    @Around("@annotation(Debug)")
    public Object beforeDebug(ProceedingJoinPoint debugJoinpoint) {
        LOGGER.debug("----------------Debug message logged from {}", debugJoinpoint.getSignature().toString());
        System.out.println("IN HERE");
        long start = System.currentTimeMillis();

        Object proceed = null;
        try {
            proceed = debugJoinpoint.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }

        long executionTime = System.currentTimeMillis() - start;

        System.out.println(debugJoinpoint.getSignature() + " executed in " + executionTime + "ms");
        return proceed;
    }
}
注释:

@Retention(RUNTIME)
@Target(METHOD)
@Loggable(type = "debug")
public @interface Debug {
}
用于测试的演示类:

@SpringBootApplication
@Component
public class Application {

    public static void main(String[] args) throws InterruptedException {
        SpringApplication.run(Application.class, args);
        dumb();
    }

    @Debug
    public static void dumb() throws InterruptedException {
        Thread.sleep(2000);
    }
}

有人能指出我做错了什么吗?这个建议不会执行,我在谷歌搜索了这里和那里后无法解决这个问题,不确定我遗漏了什么。

Spring AOP只适用于非静态方法,如Baeldung示例所示,并在Spring手册中有记录。

它在演示类中,用@debugThank注释了该方法,它起作用了。你能回答另一个问题吗?我对此很困惑。我已经读了你的很多答案,如果你知道的话,请帮忙。