Failure of Spring Boot AOP comment interception

expectation: define an annotation yourself using SpringBoot + AOP, and intercept the method of placing annotations through AOP.
has a problem: it can be intercepted when annotations are placed on methods with controller entry annotations such as GetMapping, but not when annotations are liberated to other methods.

main code:

  1. comments
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Lock {
}

2. Section

@Aspect
@Component
public class HelloAspect {


    @Around("@annotation(myLock)")
    public Object around(ProceedingJoinPoint pjp, Lock myLock) {
        //
        System.out.println("in around");
        try {
            return pjp.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return null;
        }
    }


}

3.Controller

@RestController
public class HelloController {


    // 
    @GetMapping("/hello2")
    @Lock
    public String hello2() {
        return "hello2";
    }

    @GetMapping("/hello")
    public String hello() {
        a();
        return "hello";
    }

    // 
    @Lock
    protected void a(){
        System.out.println("aaa");
    }


}
Mar.13,2021

@Autowired
private HelloController helloController;
helloController.a()

helloController is a proxy object, so calling AOP will take effect.
calling the a () method directly is the current object call, not a proxy object, so it is invalid

.

should be something annotated by @ RestController. You can use annotations such as @ Service to try

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf1823-31d98.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf1823-31d98.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?