How does a Spring Boot application start up?

A Spring application starts by creating and initializing the Spring Container, also known as the ApplicationContext. The container is responsible for scanning classes, creating beans, injecting dependencies, loading configurations, and managing the complete lifecycle of the application. In Spring Boot, this process is automatically initiated through the SpringApplication.run() method.

Key Points

Application Startup Flow

main()

|

SpringApplication.run()

|

Create ApplicationContext

|

Component Scanning

|

Bean Creation

|

Dependency Injection

|

Auto-Configuration

|

Embedded Server Startup

|

Application Ready

Step 1: Application Entry Point

Every Spring Boot application starts from the main method.

@SpringBootApplication
public class EmployeeApplication {

    public static void main(String[] args) {

        SpringApplication.run(
                EmployeeApplication.class,
                args);
    }
}

The run() method triggers the complete startup process.

Step 2: Create ApplicationContext

Spring creates an ApplicationContext.

The ApplicationContext

It acts as the central container of the application.

Step 3: Component Scanning

Spring scans packages starting from the package containing the main class.

It looks for annotations such as

Example

@Service
public class EmployeeService {

}

Spring automatically detects and registers this class as a bean.

Step 4: Bean Creation

After discovering components, Spring creates bean instances.

Example

@Service
public class EmployeeService {

}

@Repository
public class EmployeeRepository {

}

Both classes become managed beans inside the container.

Step 5: Dependency Injection

Spring resolves dependencies and injects them automatically.

Example

@Service
public class EmployeeService {

    private final EmployeeRepository repository;

    public EmployeeService(
            EmployeeRepository repository) {

        this.repository = repository;
    }
}

Spring creates EmployeeRepository first and injects it into EmployeeService.

Step 6: Auto-Configuration

Spring Boot automatically configures components based on project dependencies.

Example

If the project contains

spring-boot-starter-data-jpa

Spring Boot automatically configures

without requiring manual setup.

Step 7: Load Configuration Properties

Spring loads configuration values from

Example

server.port=9090

spring.datasource.url=jdbc:mysql://localhost/testdb

These values are applied during startup.

Step 8: Start Embedded Server

For web applications, Spring Boot starts an embedded server.

Supported Servers

Example

spring-boot-starter-web

automatically starts Tomcat.

The application becomes accessible through

http://localhost:8080

Step 9: Application Ready

After all beans are initialized and the server starts, the application is ready to process requests.

Example

Suppose an Employee Management application contains

During startup

1. SpringApplication.run() is called.

2. ApplicationContext is created.

3. Components are scanned.

4. Beans are instantiated.

5. Dependencies are injected.

6. Auto-configuration is applied.

7. Tomcat starts.

8. REST endpoints become available.

Benefits of the Spring Startup Process

Real-World Example

In a Spring Boot microservice

PaymentService Application

When the application starts

All of this happens automatically through Spring Boot's startup mechanism.

Interview Tip

A concise interview answer is

A Spring application starts when SpringApplication.run() is executed. Spring creates the ApplicationContext, scans components, creates and injects beans, applies auto-configuration, loads configuration properties, and starts the embedded server if it is a web application. Once initialization is complete, the application is ready to handle requests.

Last updated: 11 November 2026

Previous question: What are Spring Boot starter dependencies?

Next question: What does the @SpringBootApplication annotation do internally?

More Spring Boot - Level I interview questions

All Spring Boot - Level I questions