How does Spring Boot work internally?

Spring Boot simplifies application development by automatically configuring the application based on the dependencies present in the project. Internally, it starts the Spring container, performs component scanning, creates and manages beans, applies auto-configuration, and launches an embedded server when required. This allows developers to focus on business logic instead of extensive framework configuration.

Key Points

High-Level Startup Flow

Application Starts

|

@SpringBootApplication

|

SpringApplication.run()

|

Create ApplicationContext

|

Component Scanning

|

Bean Creation

|

Auto-Configuration

|

Embedded Server Starts

|

Application Ready

Step 1: Application Startup

Every Spring Boot application starts with

@SpringBootApplication
public class EmployeeApplication {

    public static void main(String[] args) {

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

SpringApplication.run() performs the complete bootstrapping process.

Step 2: Create Application Context

Spring Boot creates an ApplicationContext.

The ApplicationContext

It acts as the central container of the application.

Step 3: Component Scanning

@SpringBootApplication includes

@ComponentScan

Spring scans packages for

Example

@Service
public class EmployeeService {

}

Spring automatically detects and registers this class as a bean.

Step 4: Bean Creation and Dependency Injection

Spring creates all discovered beans.

Example

@Service
public class EmployeeService {

}

@Repository
public class EmployeeRepository {

}

Spring automatically injects dependencies.

Example

@Service
public class EmployeeService {

    @Autowired
    private EmployeeRepository repository;
}

The container manages these relationships automatically.

Step 5: Auto-Configuration

One of the most important features of Spring Boot is

@EnableAutoConfiguration

This annotation is included inside

@SpringBootApplication

Spring Boot examines

Then it automatically configures required components.

Example

If Spring Boot finds

spring-boot-starter-data-jpa

and

mysql-connector-j

It automatically creates

without manual configuration.

Step 6: Load Configuration Properties

Spring Boot loads properties from

Example

server.port=9090

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

These values are injected into the application during startup.

Step 7: Embedded Server Initialization

For web applications, Spring Boot automatically starts an embedded server.

Supported Servers

Example

spring-boot-starter-web

automatically includes Tomcat.

The server starts and begins listening for requests.

Example

http://localhost:8080

Step 8: Request Handling

When a request arrives

Client Request

|

DispatcherServlet

|

Controller

|

Service

|

Repository

|

Database

Spring MVC routes the request to the appropriate controller method.

Step 9: Actuator and Monitoring

If Spring Boot Actuator is included, additional monitoring features are enabled.

Examples

Endpoints

/actuator/health

/actuator/metrics

Example

Suppose a project contains

At startup Spring Boot

1. Creates ApplicationContext.

2. Scans all packages.

3. Creates beans.

4. Injects dependencies.

5. Configures database connection.

6. Starts Tomcat.

7. Makes REST APIs available.

All of this happens automatically with minimal configuration.

What Does @SpringBootApplication Do Internally?

@SpringBootApplication combines

@Configuration

@EnableAutoConfiguration

@ComponentScan

This single annotation triggers most of Spring Boot's startup process.

Benefits of Internal Architecture

Interview Tip

A concise interview answer is

Internally, Spring Boot starts the application using SpringApplication.run(), creates the ApplicationContext, performs component scanning, creates and injects beans, applies auto-configuration based on project dependencies, loads configuration properties, and starts an embedded server such as Tomcat for web applications. This automation significantly reduces manual configuration and accelerates application development.

Last updated: 11 November 2026

Previous question: Why do we prefer Spring Boot over Spring?

Next question: What are Spring Boot starter dependencies?

More Spring Boot - Level I interview questions

All Spring Boot - Level I questions