How to enable with java-based annotations

Did you create an aspect bean in the same @Configuration class?
Here’s what the docs suggest:

 @Configuration
 @EnableAspectJAutoProxy
 public class AppConfig {
     @Bean
     public FooService fooService() {
         return new FooService();
     }

     @Bean // the Aspect itself must also be a Bean
     public MyAspect myAspect() {
         return new MyAspect();
     }
 }

Leave a Comment