Migrate from Java 11 to Java 21 with Spring Boot 3.2.0 #72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrate from Java 11 to Java 21 with Spring Boot 3.2.0
Summary
This PR migrates the Spring Boot RealWorld Example Application from Java 11 to Java 21, upgrading Spring Boot from version 2.6.3 to 3.2.0. This is a major version upgrade that includes three main code migrations:
javax.*imports withjakarta.*(affecting validation and servlet APIs across 19 files)DateTimewith Java'sInstantAPI (affecting 16 files including serialization, MyBatis handlers, and domain entities)WebSecurityConfigfrom deprecatedWebSecurityConfigurerAdapterto the newSecurityFilterChainpattern with lambda DSLBuild Configuration Changes
Review & Testing Checklist for Human
/articles/feed,/users,/users/login, GraphQL endpoints). The Spring Security configuration was completely refactored and needs validation.2023-12-07T10:30:00.000Z). The DateTime → Instant migration should preserve format, but needs verification.Notes
WebSecurityConfig.javahas been completely refactored from the deprecatedWebSecurityConfigurerAdapterpattern to the newSecurityFilterChainbean approach with lambda DSL. While this follows Spring's official migration guide, it's the highest risk change and requires careful review of authorization rules.java.time.Instantinstead of Joda-Time'sDateTime. Jackson serialization usesDateTimeFormatter.ISO_INSTANTwhich should produce the same format as the oldISODateTimeFormat.dateTime().withZoneUTC().print().DateTimeHandlernow usesTimestamp.from(instant)andtimestamp.toInstant()for SQL conversion, maintaining UTC timezone handling.DateTimeCursorpagination still uses epoch milliseconds (Instant.toEpochMilli()) for backward compatibility.Link to Devin run: https://app.devin.ai/sessions/d946d4f51bd2439db061dbf370041c87
Requested by: @milind-cognition