-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Description
Spring Boot provides the very useful ApplicationRunner
and CommandLineRunner
for executing code immediately before the SpringApplication.run
method finishes.
There are many articles and StackOverflow questions (example 1, example 2) that advocate using these for the bulk of the logic within a Command Line application.
However, if you use one of these, then the "Started ApplicationName in X seconds" log message is output after the runners have finished. Additionally, the event ApplicationReadyEvent
is called afterwards as well.
This implies that runners are only intended for initialisation work. You should not, in fact, be using them for work that should be considered part of running the application and doing so is a misuse of their intended purpose.
Can we please have some clarity on the proper usage added to the documentation if this is indeed a misuse?
If it is not a misuse then can the runner execution get moved to after the ApplicationReadyEvent
, and after the "Started" log message, to more clearly indicate that the application is already, in fact, ready, and now the runner execution is part of the application itself running?