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: • SpringApplication is the entry point that bootstraps the application. • Auto-configuration automatically configures beans based on project dependencies. • Component scanning discovers and registers Spring-managed beans. • Embedded servers such as Tomcat start automatically for web applications. • The ApplicationContext manages the lifecycle of all beans.
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:
Code Example:
@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:
• Stores beans • Manages dependencies • Controls bean lifecycle • Handles dependency injection
It acts as the central container of the application.
Step 3: Component Scanning
@SpringBootApplication includes:
@ComponentScan
Spring scans packages for:
• @Component • @Service • @Repository • @Controller • @RestController
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:
• Classpath dependencies • Existing beans • Configuration properties
Then it automatically configures required components.
Example:
If Spring Boot finds:
spring-boot-starter-data-jpa
and
mysql-connector-jIt automatically creates:
• DataSource • EntityManagerFactory • TransactionManager
without manual configuration.
Step 6: Load Configuration Properties
Spring Boot loads properties from:
• application.properties • application.yml • Environment variables • Command-line arguments
Example:
server.port=9090
spring.datasource.url=jdbc:mysql://localhost/testdbThese 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:
• Tomcat (Default) • Jetty • Undertow
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:
• Health checks • Metrics • Environment information • Bean information
Endpoints:
/actuator/health
/actuator/metrics
Example: Suppose a project contains:
• EmployeeController • EmployeeService • EmployeeRepository
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
• Marks the class as a configuration source.
@EnableAutoConfiguration
• Enables auto-configuration.
@ComponentScan
• Scans and registers Spring beans.
This single annotation triggers most of Spring Boot's startup process.
Benefits of Internal Architecture
• Reduced configuration effort • Faster development • Automatic dependency wiring • Embedded server support • Production-ready features • Easy integration with Spring ecosystem
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."