Home / Insights / Architecture and Modernization
Architecture and Modernization
Java Modernisation: Upgrading to Java 21 and Spring Boot 3 Without a Big Bang
Open source support for Spring Boot 2.x ended in November 2023, and Java 21 is now the current long-term support release. Many teams know they need to move but fear a months-long freeze. This guide sets out a stepwise path that keeps shipping while the platform changes underneath.
TopicsArchitecture and ModernizationWeb and SaaS Development
Key takeaways
- Spring Boot 2.7.18, released in November 2023, was the last open source release of Spring Boot 2.x; staying on it now means paid support or unpatched dependencies.
- Spring Boot 3 requires Java 17 or later and moves from javax to jakarta packages; Java 21 is the newest LTS and adds virtual threads, which Spring Boot 3.2 supports.
- Separate the moves: first the latest 2.7.x on the current Java, then the Java upgrade, then Spring Boot 3.0, then later 3.x minors. Each step is releasable on its own.
- Automated refactoring such as OpenRewrite handles much of the mechanical work, but behaviour changes in Spring Security 6, Hibernate 6 and URL matching need tests and human review.
- In a multi-service estate, upgrade shared libraries and a low-risk pilot service first, then roll out service by service with a fixed playbook.
On this page
- Why the upgrade can no longer wait
- What actually changes between Spring Boot 2 and 3
- A stepwise path that avoids a big bang
- Using automated refactoring without trusting it blindly
- Testing strategy: proving nothing important changed
- Rolling out across a multi-service estate
- Risks, costs and how to contain them
- Checklist: ready to start the upgrade?
- Frequently asked questions
- Sources and methodology
Java estates tend to age quietly. A set of Spring Boot 2 services built on Java 8 or 11 can run reliably for years, until a security advisory lands for a library that no longer ships fixes for your version, or a new integration needs a dependency that only supports Spring Boot 3. At that point the upgrade becomes urgent and is often attempted all at once.
This article is for CTOs, engineering managers and architects responsible for Java and Spring Boot systems. It explains the support position as of August 2024, why Java 21 and Spring Boot 3 are the right targets, how to break the upgrade into releasable steps, where the real effort hides, and how to roll it out across many services without freezing feature work. It draws on Spring’s own migration guidance and on what we see when upgrading client systems.
Why the upgrade can no longer wait
Two clocks are running. The first is Spring Boot. In its announcement of Spring Boot 2.7.18 on 23 November 2023, the Spring team said this release marked the end of open source support for Spring Boot 2.x after about five and a half years, urged users to upgrade to Spring Boot 3 as soon as possible, and pointed to paid support for teams that cannot move yet. Every month on 2.7 now means either a commercial support contract or an increasing number of transitive dependencies that will not receive security fixes.
The second clock is Java. Oracle’s Java SE support roadmap lists Java 17 (September 2021) and Java 21 (September 2023) as LTS releases, with Premier Support for 17 until September 2026 and for 21 until September 2028. Java 8 and 11 are still covered under extended arrangements from various vendors, but the ecosystem’s attention has moved on, and Spring Boot 3 will not run on either.
Why Java 21 rather than 17
Spring Boot 3 needs Java 17 as a minimum, so 17 is a legitimate target. We usually recommend going straight to 21 when you are making the jump anyway, because it has a longer support horizon and several features worth having. The OpenJDK JDK 21 project page lists, among others:
- Virtual threads (JEP 444): lightweight threads that make thread-per-request code scale far better for I/O-heavy services, without rewriting to reactive frameworks.
- Pattern matching for switch (JEP 441) and record patterns (JEP 440): clearer code for data-heavy domain logic.
- Sequenced collections (JEP 431): consistent APIs for ordered collections.
- Generational ZGC (JEP 439): a low-pause garbage collector option that suits latency-sensitive services.
Spring Boot 3.2, released in November 2023, added support for virtual threads, which you enable with the spring.threads.virtual.enabled property when running on Java 21. That makes Java 21 plus Spring Boot 3.2 or later the combination that delivers the most value from the effort.
What actually changes between Spring Boot 2 and 3
The official Spring Boot 3.0 migration guide is the reference. For planning purposes, the changes fall into categories with very different effort and risk profiles.
| Change | What it means | Effort | Risk |
|---|---|---|---|
| Java 17 baseline | Upgrade JDK, build tools and container images; fix removed or encapsulated JDK internals | Low to medium | Medium where old libraries use reflection on JDK internals |
| javax to jakarta | Package rename for Servlet, JPA, validation and related APIs; dependency coordinates change | High volume, mostly mechanical | Low if automated, but every library must have a Jakarta version |
| Configuration properties | Several properties renamed or removed, for example server.max-http-header-size | Low | Medium: silently ignored properties change behaviour |
| Trailing slash matching | Off by default, so /orders/ no longer matches /orders | Low | High for public APIs and integrations |
| Spring Security 6 | Configuration model changes; filter behaviour and defaults differ | Medium | High: security regressions are the costliest kind |
| Hibernate 6.1 and data libraries | New group IDs, query and ID generation behaviour changes; Flyway, Liquibase and Spring Batch upgrades | Medium to high | High where custom queries or batch jobs are extensive |
| Removed integrations | Support for libraries such as EhCache 2, Hazelcast 3 and ActiveMQ removed | Varies | Medium: needs a replacement decision |
The mechanical changes, especially the Jakarta rename, look frightening because they touch many files. In practice they are the most automatable part. The changes that deserve senior attention are the behavioural ones: security configuration, URL matching, persistence and batch processing.
A stepwise path that avoids a big bang
The migration guide recommends upgrading to the latest 2.7.x first and removing deprecated APIs before moving to 3.0. The 2.7.18 announcement adds that teams should not jump straight to the newest release, but go from the latest 2.7.x to the latest 3.0.x, then 3.1.x, and so on. Combining that with the Java upgrade gives a sequence where each step is a normal release:
- Get to the latest Spring Boot 2.7.x on your current Java version. Fix every deprecation warning. Optionally move to Spring Security 5.8, which was designed as a bridge to 6.0.
- Upgrade the JDK to 17 or 21 while still on Spring Boot 2.7. Spring Boot 2.7 runs on Java 17, so you can isolate JDK issues (old bytecode tools, reflection on internals, build plugins) from framework issues.
- Clean up dependencies. Compare dependency management between 2.7 and 3.0, upgrade or replace libraries without Jakarta versions, and align unmanaged dependencies such as Spring Cloud.
- Move to Spring Boot 3.0. Apply the javax-to-jakarta rename, add
spring-boot-properties-migratortemporarily to report renamed properties, fix security and data changes, and run the full test suite. - Step through 3.1, 3.2 and onwards to the current release line, reading each release’s notes. These steps are usually small.
- Adopt Java 21 features deliberately. Enable virtual threads per service after load testing, not as part of the framework upgrade.
Each step can ship to production on its own. If a step causes problems, you roll back one step, not the whole programme. This is the same principle as the Strangler Fig approach we describe in modernising a monolith with the Strangler Fig pattern, applied to the platform rather than to features.
Illustrative example
For example, an insurance broker with twelve Spring Boot 2.5 services on Java 11 might spend the first sprint bringing all services to 2.7.x, the next moving the JDK to 21 in container images and CI, then take one low-traffic service through the 3.0 upgrade as a pilot to produce a playbook. The remaining services follow in waves, two or three per sprint, alongside normal feature work. These numbers are assumptions for illustration only.
Using automated refactoring without trusting it blindly
Automated refactoring tools now handle a large part of the mechanical work. The OpenRewrite UpgradeSpringBoot_3_0 recipe, for example, is a composite that upgrades the project to Java 17, updates Spring Boot, Spring Framework and build plugins, migrates javax packages to jakarta, renames changed properties, moves auto-configuration registration to the new imports file, and includes migrations for Spring Security 6, Spring Batch 5 and Hibernate 6.1. It can be run through Maven or Gradle plugins without permanent build changes.
Where tools help most
- Package and import renames across hundreds of files.
- Build file updates: parent POM, plugin and dependency versions.
- Known property renames and API replacements.
- Producing a consistent first pass across many services, which makes code review faster.
Where people are still needed
- Spring Security configuration, where the intent of the old setup must be understood before it is rewritten.
- Custom JPQL, native queries and ID generation under Hibernate 6.
- Libraries with no Jakarta version, which need a replacement decision.
- URL matching and API contracts consumed by partners or mobile apps.
- Performance and memory behaviour on the new JDK and garbage collector.
Run the tool on a branch, review the diff like any other pull request, and treat its output as a starting point. The value is in making the boring 80 per cent fast so engineers can focus on the risky remainder.
Testing strategy: proving nothing important changed
An upgrade’s intended outcome is that users notice nothing. Testing therefore focuses on detecting unintended change.
- Contract tests for every external API. Trailing slash behaviour, error response formats, date serialisation and header handling can all change subtly. Consumer-driven contract tests or recorded request and response comparisons catch these.
- Security regression tests. Write explicit tests for who can access what: anonymous, authenticated and each role, for representative endpoints. Run them before and after the Spring Security upgrade.
- Persistence tests against a real database. Use the same database engine as production, ideally with Testcontainers, so Hibernate 6 query changes surface in CI rather than in production.
- Batch job comparisons. For jobs that produce files or reports, compare outputs from the old and new versions on the same input.
- Load tests on the new JDK. Measure throughput, latency and memory. Do this again when enabling virtual threads, because connection pools and synchronised blocks can become the new bottleneck.
If test coverage is thin, invest in these targeted tests before the upgrade rather than trying to reach a coverage percentage. The pipeline structure in our guide to designing a CI/CD pipeline shows where such quality gates fit.
Rolling out across a multi-service estate
Microservice estates add coordination problems: shared libraries, a common parent POM, platform images and services owned by different teams.
- Inventory. List every service with its Spring Boot version, Java version, key dependencies, owner and business criticality.
- Upgrade shared foundations first. Internal libraries and the parent POM need versions for both Spring Boot 2.7 and 3 during the transition, or a clear cut-over point.
- Pilot one service. Choose something real but low risk. Record every problem and fix in a playbook.
- Wave planning. Group services by similarity (same data stack, same messaging) and criticality. Upgrade the simplest and least critical first.
- Keep feature work flowing. Upgrade branches should be short-lived; merge each step as soon as it is green rather than maintaining a long-running migration branch.
- Track and close. Maintain a simple dashboard of services by version, and set a date by which no service remains on 2.x.
Deployment and cutover practices from planning a zero-downtime migration apply to services whose schema or messaging formats change during the upgrade. Afterwards, the habits in planning framework and runtime upgrades before they become emergencies keep the next upgrade small.
Risks, costs and how to contain them
| Risk | Early warning sign | Mitigation |
|---|---|---|
| A critical library has no Jakarta version | Dependency review shows abandoned or javax-only artefacts | Identify in step 3; replace or isolate before the 3.0 move |
| Security behaviour changes unnoticed | Few or no authorisation tests | Write role-based access tests before upgrading Spring Security |
| Partner integrations break on URL or format changes | Public APIs without contract tests | Contract tests; temporarily enable legacy trailing slash matching while clients adapt |
| Upgrade branch drifts from main | Long-running branch with frequent conflicts | Small steps merged quickly; tooling re-run on fresh main |
| Performance regression | No baseline measurements | Load test before and after; tune pools and GC |
Costs are driven by the number of services, test coverage, the number of unusual dependencies and how far behind you are. The biggest hidden costs we see are writing the tests that should have existed, replacing libraries abandoned before the Jakarta change, and the coordination time across teams. Budget for those explicitly, and compare the total against the cost of commercial extended support for 2.7, which only buys time rather than progress.
Checklist: ready to start the upgrade?
- Every service is inventoried with Spring Boot and Java versions, owner and criticality.
- All services are on the latest 2.7.x with deprecation warnings resolved.
- Build tools, CI runners and container images support Java 21.
- Dependencies without Jakarta versions are identified with a replacement plan.
- Contract tests cover external APIs; security tests cover roles and endpoints.
- Persistence tests run against the production database engine.
- A pilot service is chosen and a playbook will be recorded.
- Automated refactoring is set up to run on a branch, with review of every diff.
- Load tests and baselines exist for the most performance-sensitive services.
- A target date is agreed for retiring Spring Boot 2.x across the estate.
If your team needs extra hands, PoliteTech offers Java developers experienced in Spring Boot, Hibernate, Maven and Gradle, microservices and modernising legacy Java by upgrading frameworks and Java versions. They join your repositories, backlog and review process, starting with a scoped piece of work such as a pilot service.
Frequently asked questions
Can we go straight from Java 8 to Java 21?
Yes, and many teams do. The practical risk is old libraries and build plugins that rely on removed or encapsulated JDK internals, so upgrade dependencies first and run the JDK change as its own step while still on Spring Boot 2.7.
Should we target Java 17 or Java 21?
Spring Boot 3 works on both. Java 21 has a longer support horizon and adds virtual threads, which Spring Boot 3.2 and later support, so it is usually the better target if you are upgrading anyway.
Is the javax to jakarta change a big rewrite?
It touches many files but is largely mechanical, and tools such as OpenRewrite automate most of it. The real constraint is that every library you use must have a Jakarta-compatible version.
Do we need to upgrade all services at the same time?
No. Services can run different Spring Boot versions as long as their APIs and message formats stay compatible. Upgrade shared libraries first, pilot one service, then move the rest in waves.
Should we enable virtual threads as part of the upgrade?
We recommend keeping it separate. Complete the framework upgrade first, then enable virtual threads per service after load testing, because connection pools and synchronised code can behave differently.
What if we cannot upgrade before our next audit?
Commercial support for Spring Boot 2.7 is available and buys time, but it does not reduce the eventual work. Document a dated upgrade plan alongside it so the risk is visibly managed.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- Spring Blog: Spring Boot 2.7.18 available now (23 November 2023) — accessed 9 November 2026. End of open source support for Spring Boot 2.x and the recommended stepwise path through 3.0.x and later minors.
- Spring Boot wiki: Spring Boot 3.0 Migration Guide — accessed 9 November 2026. Upgrade to latest 2.7 first, Java 17 baseline, Jakarta migration, properties migrator, trailing slash matching, Spring Security 6 and Hibernate 6.1 changes.
- OpenJDK: JDK 21 project page — accessed 9 November 2026. JDK 21 GA date and features including virtual threads, pattern matching for switch, record patterns, sequenced collections and generational ZGC.
- Oracle: Java SE Support Roadmap — accessed 9 November 2026. LTS status and Premier Support dates for Java 17 and Java 21.
- Spring Blog: Spring Boot 3.2.0 available now (23 November 2023) — accessed 9 November 2026. Spring Boot 3.2 support for virtual threads, RestClient and JdbcClient.
- OpenRewrite documentation: Migrate to Spring Boot 3.0 recipe — accessed 9 November 2026. Scope of automated migration for Java 17, Jakarta, properties, Spring Security 6 and Hibernate 6.1.
Related reading
Continue your research
Still running Spring Boot 2 services and need a safe route to Java 21?
We can review your services and dependencies, run a pilot upgrade with your team and turn it into a playbook for the rest of the estate.
