How Does Spring Application Works?
Initialization of Spring Boot
The initialization of a Spring Boot application involves the following concise steps:
- SpringApplication.run(): Entry point that launches the application.
- Environment Preparation: Sets up the application environment, including configuration properties and profiles.
- Application Context Creation: Creates the
ApplicationContext (e.g., AnnotationConfigApplicationContext).
- Bean Definition Loading: Scans and registers beans and their dependencies.
- Listeners and Initializers: Registers and invokes application listeners and initializers.
- Context Refreshing: Instantiates, configures, and wires beans; starts the embedded web server if applicable.
- Post-Processing: Executes any
CommandLineRunner and ApplicationRunner beans.
- Ready State: Publishes the
ApplicationReadyEvent signaling the application is ready to handle requests.
What is Spring Container?
The Spring container is a core component of the Spring Framework. It is responsible creating and managing the lifecycle and configuration of application objects (Beans). The Container reads configuration metadata to know how to initiate, configure, and assemble these beans. This metadata can be supplied in various forms such as XML, annotations, or Java code.
Responsibility of IOC Container
- Instantiating beans: Creating instances of the beans defined in the configuration.
- Wiring beans: Managing dependencies between beans.
- Configuring beans: Setting properties and managing initialization and destruction callbacks.
- Managing the bean lifecycle: Handling the complete lifecycle of a bean from creation to destruction.

Note: To understand more about setting up configuration metadata read this documentation What is Spring IOC Container with Example (javaguides.net)