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;
@Retention(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;
@Aspect
@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
@Entity
@AopAudit
public class ABC {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@NotEmpty
@NotNull
@Column
private String name;
//... getters and setters
}
configuration class
@Configuration
@EnableWebSecurity
@EnableAspectJAutoProxy
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