Spring AOP not getting invoked in spring boot 2.1.6 application

Tags: , , , ,

After following so many search results on google on this subject, my Aspect doesn’t work still on my spring boot application

I am using spring boot version 2.1.6, which seem to have already spring aop, aspectjweaver and aspectjrt (stand to be corrected). i created an annotation, aspect component and use my annotation on a target class with no success.

here is my annotation class

    import java.lang.annotation.Retention;
    import java.lang.annotation.Target;

    import static java.lang.annotation.ElementType.*;
    import static java.lang.annotation.RetentionPolicy.RUNTIME;

    @Target({TYPE, METHOD})
    public @interface AopAudit {

my aspect class

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

    public class AuditAnnotationAspect {
        @Before("execution(* com.rainestech.hrm.modules.settings.entity.ABC.set*(..))")
        public void before(JoinPoint joinPoint) {
    System.out.println("Audit Works!!! = ");

class ABC

public class ABC {

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    private String name;

    //... getters and setters

configuration class

public class WebSecurity extends WebSecurityConfigurerAdapter {


running the application and running set method on class ABC produce no effect whereas i expect to see Audit Works in the console


First, make sure your pom.xml contains all of these:




Second, annotate your configuration with @EnableAspectJAutoProxy, this will enable it.

Third, make sure you update your pointcut:

private void auditable() {}

And then use it in your @Before.


Another important thing to notice is that you cannot execute a method pointcut of which is located on the same class. More info here.

Source: stackoverflow