Skip to content

Spring Boot 4.0.1 Upgrade

Choose a tag to compare

@darbyluv2code darbyluv2code released this 31 Dec 19:53
· 32 commits to main since this release

Spring Boot 4.0.1 Major Version Upgrade

All Spring Boot projects have been upgraded from version 3.5.9 to 4.0.1. This is a major version upgrade with breaking changes.

Projects Updated

  • 01-books
  • 02-books-continued
  • 03-spring-boot-rest-security/employees
  • 04-todos

Dependency Updates

All Projects

  • Spring Boot: 3.5.9 → 4.0.1 (major version)
  • Spring Framework: 6.x → 7.x (auto-managed by Spring Boot parent)
  • Jackson: 2.x → 3.x (auto-managed, breaking change)
  • SpringDoc OpenAPI: Updated to 3.0.1 for Jackson 3 compatibility
    • 01-books: 2.8.3 → 3.0.1
    • 02-books-continued: 2.8.3 → 3.0.1
    • 03-employees: 2.1.0 → 3.0.1
    • 04-todos: 2.8.3 → 3.0.1
  • Spring Boot Starters: Migrated to Spring Boot 4 starters
    • spring-boot-starter-web → spring-boot-starter-webmvc
    • spring-boot-starter-test → spring-boot-starter-webmvc-test

Project 04-todos Only

  • JJWT: 0.11.5 → 0.13.0 (API migration and minor updates)
    • 0.11.5 → 0.12.6: Breaking API changes
    • 0.12.6 → 0.13.0: Fully backwards compatible (maintenance release)
  • JJWT Dependencies: Optimized with runtime scope for jjwt-impl and jjwt-jackson

Breaking Changes

Spring Boot 4 Starter Migration (All Projects)

Spring Boot 4.0 deprecated generic starters in favor of more specific ones:

Web Starter:

<!-- Deprecated -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- New in Spring Boot 4 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>

Test Starter:

<!-- Deprecated -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

<!-- New in Spring Boot 4 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webmvc-test</artifactId>
    <scope>test</scope>
</dependency>

These changes provide better modularity and make it explicit that projects use Spring WebMVC (not WebFlux).

JJWT 0.12.6 API Migration (04-todos)

The JWT token service (JwtServiceImpl.java) was updated to use the new JJWT 0.12 API:

Token Parsing Changes:

  • Jwts.parserBuilder() → Jwts.parser()
  • setSigningKey() → verifyWith()
  • parseClaimsJws() → parseSignedClaims()
  • getBody() → getPayload()

Token Generation Changes:

  • Setter methods changed to fluent methods (e.g., setClaims() → claims())
  • SignatureAlgorithm.HS256 → Jwts.SIG.HS256
  • Method signature: Key → SecretKey for signing key type

JJWT 0.13.0 Update (04-todos)

JJWT upgraded from 0.12.6 to 0.13.0 with zero breaking changes:

  • Fully backwards compatible with 0.12.6
  • Removed unnecessary type casts in JwtServiceImpl
  • No deprecation warnings
  • Last release supporting Java 7 (future 0.14.0+ requires Java 8+)

JJWT Dependency Optimization

Following JJWT best practices, implementation dependencies now use runtime scope:

<!-- API - compile scope (public interfaces) -->
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-api</artifactId>
    <version>0.13.0</version>
</dependency>

<!-- Implementation - runtime scope (internal classes) -->
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-impl</artifactId>
    <version>0.13.0</version>
    <scope>runtime</scope>
</dependency>

<!-- JSON Processor - runtime scope (auto-detected) -->
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-jackson</artifactId>
    <version>0.13.0</version>
    <scope>runtime</scope>
</dependency>

Benefits:

  • Better encapsulation - code depends only on public API
  • Protected from internal implementation changes
  • Follows official JJWT recommendations
  • Separates compile vs runtime concerns

Technical Details

  • All projects compile successfully with Maven Compiler Plugin 3.14.1
  • Java 25 compatibility maintained (no changes required)
  • No code changes required for projects 01, 02, and 03
  • Project 04 JWT implementation fully migrated to JJWT 0.13 API
  • SpringDoc OpenAPI 3.0.1 required for Jackson 3 support
  • Spring Boot 4 WebMVC starters eliminate deprecated dependency warnings

Compatibility

  • Requires JDK 25 to build and run
  • All third-party dependencies compatible with Spring Boot 4.0.1
  • Total source files compiled: 53 across all projects

Migration Reference

For more details on Spring Boot 4.0 changes, see the official migration guide:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide