Spring Boot 3 (November 2022) — a major update with many breaking changes.
Simple analogy: Spring Boot 2 → 3 is like moving to a new house. Old furniture (javax) doesn't fit, you need new (jakarta). But the house is better: warmer (Java 17+), more spacious (Virtual Threads), smarter (Observability built-in). It is not a cosmetic update — it is a fundamental modernization of the platform.
Why it matters: Spring Boot 2 reached end of life. Every new project should start with Spring Boot 3. The migration is non-trivial (especially javax → jakarta), but the benefits — native image support, virtual threads, built-in observability, improved security — make it essential.
Key changes:
1. Java 17+ (minimum):
1<java.version>17</java.version>
Java 17 enables sealed classes, records, pattern matching, and text blocks — all used internally by Spring Boot 3.
2. javax → jakarta (the biggest migration effort):
1// Before (Spring Boot 2)2import javax.persistence.Entity;3import javax.servlet.http.HttpServletRequest;4import javax.validation.constraints.NotBlank;56// After (Spring Boot 3)7import jakarta.persistence.Entity;8import jakarta.servlet.http.HttpServletRequest;9import jakarta.validation.constraints.NotBlank;
Every import, every XML namespace, every dependency that references javax must change to jakarta.
3. GraalVM Native Image:
1<dependency>2 <groupId>org.springframework.boot</groupId>3 <artifactId>spring-boot-starter-aot</artifactId>4</dependency>
1./mvnw -Pnative native:compile2# Result: ./target/myapp (~50MB, startup in 10ms, lower memory usage)
Native images compile Java to native machine code — no JVM required. Startup drops from seconds to milliseconds, memory usage drops from hundreds of MB to tens of MB.
4. Virtual Threads (opt-in, Java 21+):
1spring:2 threads:3 virtual:4 enabled: true # Spring Boot 3.2+
Virtual threads give you WebFlux-level throughput with standard MVC code. One million concurrent connections without reactive programming.
5. Observability (Micrometer + Tracing):
1<dependency>2 <groupId>io.micrometer</groupId>3 <artifactId>micrometer-tracing-bridge-otel</artifactId>4</dependency>
Built-in distributed tracing — every HTTP call, database query, and message send is automatically traced with trace IDs in logs.
6. Deprecated / Removed:
spring.factories → AutoConfiguration.imports (new registration mechanism).@ConstructorBinding not needed (constructors are default now).server.error.include-message = never (security — error messages are hidden by default).WebMvcConfigurerAdapter removed — use WebMvcConfigurer directly.7. Spring Security 6:
1// Before (Security 5):2// http.authorizeRequests().antMatchers("/api/**").authenticated()34// After (Security 6):5http.authorizeHttpRequests(auth -> auth6 .requestMatchers("/api/public/**").permitAll()7 .requestMatchers("/api/**").authenticated()8);
8. Problem Detail (RFC 7807):
1// Standardized error responses2@RestControllerAdvice3public class GlobalExceptionHandler {4 @ExceptionHandler(UserNotFoundException.class)5 public ProblemDetail handleNotFound(UserNotFoundException ex) {6 ProblemDetail problem = ProblemDetail.forStatusAndDetail(7 HttpStatus.NOT_FOUND, ex.getMessage());8 problem.setTitle("User Not Found");9 return problem;10 }11}
Migration tips:
spring-boot-migrator) for automated javax → jakarta changes.