Search code examples
spring-bootoperator-precedence

Spring boot, how to specify the order when multiple @EventListener(ApplicationReadyEvent.class)


I have a class that runs after the App starts, it has the annotation:

@EventListener(ApplicationReadyEvent.class)

Which is ok, the problem is that in my project there is a library(dependency) with the same annotation and it runs after mine, I need to specify the order/priority so the code at the dependency is executed before mine..


Solution

  • You can use @Order(value=x)

    Where x = the needed order value