When using several aspect classes, it can be necessary to set the order in which the aspects are executed. In this recipe, we will use two aspect classes with before advices targeting controller methods.
We will use the configuration from the Creating a Spring AOP aspect class recipe.
We will use these two aspect classes containing an advice, which logs some text when it's executed:
@Component @Aspect public class Aspect1 { @Before("execution(* com.spring_cookbook.controllers.*.*(..))") public void advice1() { System.out.println("advice1"); } } @Component @Aspect public class Aspect2 { @Before("execution(* com.spring_cookbook.controllers.*.*(..))") public void advice2() { System.out.println("advice2"); } }