Introduction to Spring Boot
Spring Boot makes it easy to create stand-alone, production-ready Spring applications with minimal configuration. It embraces convention over configuration — you write business logic, not boilerplate.
The problem Spring Boot solves
Classic Spring required extensive XML configuration or Java-based @Configuration classes just to get a web app running. Spring Boot flips this: it auto-configures sensible defaults so you can go from zero to a running HTTP server in minutes. You override only what you need to change.
Spring Boot vs Spring Framework
| Spring Framework | Spring Boot | |
|---|---|---|
| Configuration | Manual — XML or @Configuration | Auto-configuration, starter POMs |
| Embedded server | Deploy WAR to external Tomcat/Jetty | Tomcat/Netty embedded — runs as a JAR |
| Startup | Heavy setup required | One main class, one annotation |
| Dependencies | Choose & version each individually | Starter bundles handle compatible sets |
| Production-ready | Manual setup for health/metrics | Actuator endpoints built-in |
Key features
- Auto-configuration: Spring Boot detects JARs on the classpath and configures beans automatically.
- Starter dependencies:
spring-boot-starter-webpulls in MVC, Jackson, and an embedded Tomcat with one entry. - Embedded server: no WAR, no external app server — just
java -jar app.jar. - Actuator: health checks, metrics, environment info via HTTP endpoints out of the box.
- Spring Initializr: generate a project skeleton at start.spring.io.
Project structure
my-app/
├── src/
│ ├── main/
│ │ ├── java/com/example/myapp/
│ │ │ ├── MyAppApplication.java ← entry point (@SpringBootApplication)
│ │ │ ├── controller/ ← REST controllers
│ │ │ ├── service/ ← business logic
│ │ │ ├── repository/ ← data access (Spring Data)
│ │ │ └── model/ ← entity / DTO classes
│ │ └── resources/
│ │ ├── application.properties ← configuration
│ │ └── static/ ← served as-is (HTML, CSS, JS)
│ └── test/
│ └── java/com/example/myapp/ ← test classes
├── pom.xml ← Maven build descriptor
└── mvnw ← Maven wrapper (no local Maven needed)
The entry point
package com.example.myapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication // = @Configuration + @EnableAutoConfiguration + @ComponentScan
public class MyAppApplication {
public static void main(String[] args) {
SpringApplication.run(MyAppApplication.class, args);
}
}
That's it. @SpringBootApplication triggers component scanning of the package and all sub-packages, and enables auto-configuration for any starter jars on the classpath.
Maven starter
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.0</version>
</parent>
<dependencies>
<!-- Web: REST, MVC, embedded Tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Tests: JUnit 5, Mockito, MockMvc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Common starters
| Starter | What it includes |
|---|---|
spring-boot-starter-web | Spring MVC, Jackson, embedded Tomcat, validation |
spring-boot-starter-data-jpa | Hibernate, Spring Data JPA, JDBC |
spring-boot-starter-security | Spring Security, authentication & authorization |
spring-boot-starter-test | JUnit 5, Mockito, MockMvc, AssertJ |
spring-boot-starter-actuator | Health, metrics, env, info endpoints |
spring-boot-starter-validation | Bean Validation (Hibernate Validator) |
spring-boot-starter-cache | Spring Cache abstraction (plug in Redis, etc.) |
spring-boot-starter-mail | JavaMail + Spring's MailSender |
spring-boot-starter-webflux | Reactive web with Project Reactor / Netty |
Running the application
# Maven Wrapper (no local Maven needed)
./mvnw spring-boot:run
# Or build a fat JAR and run it directly
./mvnw clean package
java -jar target/my-app-0.0.1-SNAPSHOT.jar
# The embedded Tomcat listens on port 8080 by default
curl http://localhost:8080/
Spring Initializr at start.spring.io generates a ready-to-run project. Pick your language (Java/Kotlin/Groovy), build tool (Maven/Gradle), Spring Boot version, and dependencies — then download and unzip.