Skip to content

Application startup callbacks

Application startup callbacks are mechanisms in Spring Boot used to execute specific code immediately after the ApplicationContext has been fully loaded but before the application officially starts running.^[600-developer__spring__springboot.md]

Implementation

Spring Boot provides two primary interfaces for this purpose:

  • ApplicationRunner: Used to run code after the application context is loaded.^[600-developer__spring__springboot.md]
  • CommandLineRunner: An alternative interface for executing startup logic.^[600-developer__spring__springboot.md]

These interfaces are useful for tasks such as data initialization, verification checks, or triggering processes that require the full application environment to be available.

Sources

  • 600-developer__spring__springboot.md