Hard java spring

5. What is the exact startup flow of a Spring Boot application?

Sample answer: "SpringApplication.run starts. It sends ApplicationStartingEvent, then prepares the Environment and loads config, then creates the ApplicationContext. On refresh it registers bean definitions, runs auto-configuration, creates singletons and starts the embedded server. Then ApplicationStartedEvent, then the CommandLineRunner and ApplicationRunner beans run, then ApplicationReadyEvent, and readiness becomes ACCEPTING_TRAFFIC."

  • Event order: Starting → EnvironmentPrepared → ContextInitialized → Prepared → (refresh) → Started → LivenessState.CORRECT → runners → Ready → ReadinessState.ACCEPTING_TRAFFIC.
Sources (1)
  1. SpringApplication: Application events and listeners