Skip to content

Instantly share code, notes, and snippets.

@tedysaputro
Last active December 22, 2025 02:39
Show Gist options
  • Select an option

  • Save tedysaputro/f4c28ffd0a97666077fa89eb23f63850 to your computer and use it in GitHub Desktop.

Select an option

Save tedysaputro/f4c28ffd0a97666077fa89eb23f63850 to your computer and use it in GitHub Desktop.
Migration Notes: Spring Boot 4.0.0 & Java 25 Upgrade

Migration Notes: Spring Boot 4.0.0 & Java 25 Upgrade

Tanggal Upgrade: 22 Desember 2025
Versi Sebelumnya: Spring Boot 3.4.0, Java 21
Versi Setelah Upgrade: Spring Boot 4.0.0, Java 25


πŸ“‹ Ringkasan Perubahan

Upgrade ini melibatkan perubahan major version dari Spring Boot 3.x ke 4.0.0 dan Java 21 ke Java 25. Spring Boot 4.0.0 membawa perubahan arsitektur modular baru dan dependency pada Spring Framework 7.0 serta Spring Security 7.0.


πŸ”§ Perubahan pada pom.xml

1. Spring Boot Parent Version

<!-- SEBELUM -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.4.0</version>
</parent>

<!-- SESUDAH -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>4.0.0</version>
</parent>

2. Java Version

<!-- SEBELUM -->
<properties>
    <java.version>21</java.version>
</properties>

<!-- SESUDAH -->
<properties>
    <java.version>25</java.version>
</properties>

3. Dependency Updates

a. JJWT (JSON Web Token)

<!-- TETAP MENGGUNAKAN VERSI TERBARU -->
<!-- Versi: 0.13.0 (Latest - Released Aug 20, 2025) -->
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-api</artifactId>
    <version>0.13.0</version>
</dependency>
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-impl</artifactId>
    <version>0.13.0</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-jackson</artifactId>
    <version>0.13.0</version>
    <scope>runtime</scope>
</dependency>

Status: JJWT 0.13.0 adalah versi terbaru (dirilis 20 Agustus 2025) dan SEPENUHNYA KOMPATIBEL dengan Spring Boot 4.0.0, Spring Security 7.0, dan Java 25. Versi ini sudah diverifikasi melalui build test dan berjalan tanpa error.

b. SpringDoc OpenAPI

<!-- SEBELUM: 2.8.6 -->
<!-- SESUDAH: 3.0.0 (UPGRADE) -->
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>3.0.0</version>
</dependency>

Status: SpringDoc OpenAPI 3.0.0 adalah versi terbaru yang RESMI MENDUKUNG Spring Boot 4.0.0. Versi ini mencakup upgrade ke Spring Framework 7, support untuk API versioning, dan upgrade ke Scalar 0.4.3. Sudah diverifikasi melalui build test dan berjalan tanpa error.

c. AspectJ Starter (BREAKING CHANGE)

<!-- SEBELUM -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-aop</artifactId>
</dependency>

<!-- SESUDAH - Spring Boot 4.0 Modular Design -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-aspectj</artifactId>
</dependency>

Alasan: Spring Boot 4.0 menggunakan desain modular baru dengan konvensi penamaan yang konsisten: spring-boot-starter-<technology>.

d. REST Assured

<!-- Ditambahkan versi eksplisit -->
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>spring-mock-mvc</artifactId>
    <version>5.5.0</version>
    <scope>test</scope>
</dependency>

e. Testcontainers 2.0

<!-- SEBELUM: Managed by Spring Boot -->
<!-- SESUDAH: Perlu versi eksplisit -->
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>2.0.3</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>postgresql</artifactId>
    <version>2.0.3</version>
    <scope>test</scope>
</dependency>

Catatan: Testcontainers 2.0 memiliki breaking changes:

  • Semua module sekarang menggunakan prefix testcontainers-
  • JUnit 4 support dihapus sepenuhnya
  • Container classes dipindahkan ke package module-specific

πŸ’» Perubahan Kode Java

1. Spring Security 7.0 - SkipPathRequestMatcher.java

Masalah: AntPathRequestMatcher dihapus dari Spring Security 7.0

File: src/main/java/com/subrutin/catalog/security/util/SkipPathRequestMatcher.java

// SEBELUM
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

public SkipPathRequestMatcher(List<String> pathToSkip, List<String> processingPath) {
    List<RequestMatcher> skip = pathToSkip.stream()
        .map(s -> new AntPathRequestMatcher(s))
        .collect(Collectors.toList());
    skipMacther = new OrRequestMatcher(skip);
    
    List<RequestMatcher> processing = processingPath.stream()
        .map(p -> new AntPathRequestMatcher(p))
        .collect(Collectors.toList());
    processingMatcher = new OrRequestMatcher(processing);
}

// SESUDAH - Menggunakan AntPathMatcher dari Spring Framework
import org.springframework.util.AntPathMatcher;

private static final AntPathMatcher pathMatcher = new AntPathMatcher();

public SkipPathRequestMatcher(List<String> pathToSkip, List<String> processingPath) {
    List<RequestMatcher> skip = pathToSkip.stream()
        .map(pattern -> (RequestMatcher) request -> 
            pathMatcher.match(pattern, request.getRequestURI()))
        .collect(Collectors.toList());
    skipMacther = new OrRequestMatcher(skip);
    
    List<RequestMatcher> processing = processingPath.stream()
        .map(pattern -> (RequestMatcher) request -> 
            pathMatcher.match(pattern, request.getRequestURI()))
        .collect(Collectors.toList());
    processingMatcher = new OrRequestMatcher(processing);
}

Solusi: Membuat custom RequestMatcher implementation menggunakan AntPathMatcher dari org.springframework.util yang masih tersedia.


2. Spring Security 7.0 - JwtAuthenticationToken.java

Masalah: Constructor ambiguity di AbstractAuthenticationToken

File: src/main/java/com/subrutin/catalog/security/model/JwtAuthenticationToken.java

// SEBELUM - Menyebabkan compilation error
public JwtAuthenticationToken(RawAccessJwtToken rawAccessJwtToken) {
    super(null);  // AMBIGUOUS!
    this.rawAccessJwtToken = rawAccessJwtToken;
    super.setAuthenticated(false);
}

// SESUDAH - Explicit cast untuk menghindari ambiguitas
public JwtAuthenticationToken(RawAccessJwtToken rawAccessJwtToken) {
    super((Collection<? extends GrantedAuthority>) null);
    this.rawAccessJwtToken = rawAccessJwtToken;
    super.setAuthenticated(false);
}

Alasan: Spring Security 7.0 menambahkan constructor baru di AbstractAuthenticationToken yang menyebabkan ambiguitas saat memanggil super(null). Explicit cast diperlukan untuk menentukan constructor mana yang dipanggil.


πŸ” Breaking Changes Spring Boot 4.0

1. Modular Design

Spring Boot 4.0 memperkenalkan desain modular baru dengan konvensi:

  • Main modules: spring-boot-<technology>
  • Root package: org.springframework.boot.<technology>
  • Starter POMs: spring-boot-starter-<technology>
  • Test modules: spring-boot-<technology>-test
  • Test starters: spring-boot-starter-<technology>-test

2. Dependency Upgrades

Spring Boot 4.0 menggunakan versi major baru dari:

  • Spring Framework 7.0
  • Spring Security 7.0
  • Spring Data 2025.1
  • Spring Batch 6.0
  • Hibernate 7.1
  • Micrometer 1.16
  • Reactor 2025.0

3. JUnit 6

  • JUnit 6 menjadi default testing framework
  • JUnit 4 support deprecated
  • JUnit Vintage engine deprecated

βœ… Verifikasi Build

Build Maven berhasil tanpa error:

mvn clean compile

Output:

[INFO] BUILD SUCCESS
[INFO] Total time:  4.668 s
[INFO] Finished at: 2025-12-22T08:59:03+07:00

⚠️ Warnings (Non-Critical)

1. Lombok Warnings

Generating equals/hashCode implementation but without a call to superclass

File yang terpengaruh:

  • AbstractBaseUUIDEntity.java
  • Profile.java
  • AppUser.java
  • Publisher.java

Rekomendasi: Tambahkan @EqualsAndHashCode(callSuper=false) jika memang tidak perlu memanggil superclass.

2. Deprecated API Usage

ExceptionHandlerAdvice.java uses or overrides a deprecated API

Rekomendasi: Review dan update ke API yang baru di masa depan.

3. Testcontainers POM Warning

The POM for org.testcontainers:junit-jupiter:jar:2.0.3 is missing
The POM for org.testcontainers:postgresql:jar:2.0.3 is missing

Status: Warning ini tidak mempengaruhi build. Dependencies tetap ter-resolve dengan benar.


πŸ“š Referensi

  1. Spring Boot 4.0.0 Release Notes
  2. Spring Boot 4.0 Migration Guide
  3. Spring Security 7.0 Migration Guide
  4. Testcontainers 2.0 Release
  5. JUnit 6 Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment