DEV Community

Alpha Solutions
Alpha Solutions

Posted on

A Practical Checklist for Upgrading to Java 17/21 and Spring Boot 3

I've spent 16+ years with Java and Spring Boot, and this upgrade still catches teams off guard. It isn't one change. It's a JDK baseline move, a Jakarta namespace rename, and a major Spring Boot release, and those go badly if you try to do them all at once.

This is the order I use, and it matches what the Spring team recommends: get onto the latest Spring Boot 2.7.x first, then Java 17, then Spring Boot 3. Java 21 comes after you're on a Boot 3 line that officially supports it (3.2 and later).

As of late 2026, Spring Boot 4.x is the current major line. You still have to make this 2-to-3 jump first — Java 17 and Jakarta EE are the hard part. Land on a recent 3.x, get a green build and a clean staging run, then check Spring's current supported versions for the next hop.

1. Get to the latest Spring Boot 2.7.x and clear the deprecations

Don't start from 2.4 or 2.5 and jump to 3. The official Spring Boot 3.0 migration guide assumes you are coming from 2.7.

  • Bump to the latest 2.7.x patch.
  • Fix every deprecation warning you can. Methods, classes, and properties that were deprecated in Boot 2.x were removed in 3.0.
  • Inventory libraries that Spring Boot doesn't manage (Spring Cloud, internal starters, old SOAP or JAXB stacks). Find Boot 3 / Jakarta-compatible versions before you move.
  • If you use Spring Security, consider upgrading the Boot 2.7 app to Spring Security 5.8 first. Boot 2.7 ships an older 5.7 line; 5.8 was published specifically as a bridge to Security 6, and you override the version yourself. Follow the Security team's "prepare for 6.0" guide while you're still on 2.7, then the 5.8-to-6.0 guide when you take Boot 3.

Ship this as its own release if you can. A boring 2.7 upgrade is a much better baseline than a mixed-in Jakarta rewrite.

2. Move the JDK to 17 while you are still on Boot 2.7

Spring Boot 3 requires Java 17. Boot 2.7 already runs well on 17, so do the JDK move first and keep Boot on 2.7. Don't jump to Java 21 yet: that isn't an official baseline for Boot 2.7, and Boot 3.0 was tested through JDK 19. Official Java 21 support arrives with Spring Boot 3.2.

Set the language level in the build:

<properties>
    <java.version>17</java.version>
</properties>
Enter fullscreen mode Exit fullscreen mode

In Gradle, set sourceCompatibility / targetCompatibility, or better, JavaLanguageVersion.of(17).

Watch for APIs and modules that left the JDK after 8:

  • JAXB, JAX-WS, and related Java EE modules were removed in JDK 11 (JEP 320). On Boot 2.7 / Java 17, add the javax.* artifacts you still need (javax.xml.bind:jaxb-api plus a runtime such as org.glassfish.jaxb:jaxb-runtime). When you later move to Boot 3, switch those to the Jakarta coordinates (jakarta.xml.bind:jakarta.xml.bind-api and org.glassfish.jaxb:jaxb-runtime) and update the imports. If you use spring-boot-starter-parent, omit the versions and let the BOM manage them.
  • javax.annotation types such as @PostConstruct and @Resource also left the JDK in 11. On Boot 2 you typically add javax.annotation:javax.annotation-api. On Boot 3 this becomes jakarta.annotation.
  • Nashorn was removed in JDK 15. If anything still evaluates JavaScript through javax.script with Nashorn, replace it before you leave Java 11. GraalJS is a common option if you still need a JS engine.
  • Illegal reflective access is denied by default from JDK 17 (JEP 403). The old --illegal-access flag does nothing useful on 17+. You'll see InaccessibleObjectException from older libraries that reach into java.* internals. Prefer a library version that no longer does that. If you must, open only the package you need, for example --add-opens java.base/java.lang=ALL-UNNAMED. Don't spray --add-opens across the JDK as a permanent fix.

Compile, run tests, and soak this on Java 17 before you touch Boot 3.

3. Upgrade to Spring Boot 3 (and Jakarta)

Bump the parent or BOM to a recent Spring Boot 3.x. Spring Boot 3.0 needs Java 17, Spring Framework 6, and Jakarta EE 10 APIs (Servlet 6.0, JPA 3.1, and so on). Prefer a current 3.x maintenance line over 3.0.0 itself.

javax to jakarta — don't find-and-replace

A global replace of javax to jakarta will break JDK packages that never moved: javax.sql, javax.crypto, javax.naming, javax.net, javax.management, javax.annotation.processing, javax.transaction.xa, and others.

Two tools that know the difference:

  • IntelliJ IDEA: Refactor → Migrate Packages and Classes → Java EE to Jakarta EE. Preview the diff, then apply it module by module if the repo is large.
  • OpenRewrite: the Spring Boot 3 upgrade recipes are named like org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0, with follow-on recipes for later 3.x lines. The namespace-only recipe is org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta. Check the current OpenRewrite docs for how to run them — recipe artifact distribution has changed, so an old Maven Central one-liner may not resolve.

After the rewrite, search for leftover javax.servlet, javax.persistence, javax.validation, and EE javax.annotation imports, plus XML namespace URIs in web.xml / persistence.xml. Generated sources (JAXB, OpenAPI) need the generator upgraded, not a hand-edit of the output. Libraries with no Jakarta release have to be upgraded or replaced; a recipe can't invent a compatible artifact.

Configuration properties

Add spring-boot-properties-migrator as a runtime dependency. It prints diagnostics at startup and temporarily remaps old property names. One well-known rename: Micrometer export properties moved, for example management.metrics.export.prometheus became management.prometheus.metrics.export.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-properties-migrator</artifactId>
    <scope>runtime</scope>
</dependency>
Enter fullscreen mode Exit fullscreen mode

Fix the properties, then remove the migrator. Don't ship it as a permanent crutch. Note that properties added late, such as via @PropertySource, aren't always picked up.

Spring Security 6

WebSecurityConfigurerAdapter is gone. Register a SecurityFilterChain bean, use authorizeHttpRequests, and replace antMatchers / mvcMatchers / regexMatchers with requestMatchers. Prefer the lambda DSL; later 6.x releases dropped the old chained http.csrf().disable() style.

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
public class SecurityConfiguration {

    @Bean
    SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests(auth -> auth
                .requestMatchers("/actuator/health").permitAll()
                .anyRequest().authenticated())
            .httpBasic(Customizer.withDefaults());
        return http.build();
    }
}
Enter fullscreen mode Exit fullscreen mode

Security 6 also applies authorization to every dispatcher type. If a forward or error dispatch suddenly returns 403, look at spring.security.filter.dispatcher-types before you loosen rules globally.

Hibernate 6

Boot 3.0 ships Hibernate 6.1 (later 3.x lines use later 6.x; let the BOM pick the version). Imports move to jakarta.persistence. Expect:

  • Implicit numeric ID sequences often become per-entity (for example person_seq) rather than a shared hibernate_sequence, and the default increment/allocation size is often 50. That can break inserts on an existing database. Check the Hibernate 6 migration guide and, if you need a temporary bridge, the hibernate.id.db_structure_naming_strategy setting.
  • UUID mappings and JDBC types may change; compare column types in staging.
  • Don't set hibernate.dialect unless you have a reason — Hibernate 6 can resolve it.
  • Native queries, Criteria usage, and custom UserType / AttributeConverter code are the usual breakage spots. Read the Hibernate guide for anything non-trivial.

4. Build plugins, Lombok, and Mockito

If you use spring-boot-starter-parent or the Boot Gradle plugin, plugin and dependency versions stay in sync. If you pin them yourself, bump them.

  • Set java.version (or maven.compiler.release) to 17, then 21 when you take that step.
  • Check the system requirements for your target Boot line. Boot 3.0 needed Maven 3.5+ and Gradle 7.5+; later 3.x lines need a newer Gradle.
  • Lombok: Java 21 needs Lombok 1.18.30 or newer. Don't leave a years-old pin in the POM.
  • Mockito: 5.x is what you want on Java 17 and 21. On Java 21, the JDK restricts dynamic agent attach; if tests warn or fail when Mockito instruments classes, attach mockito-core as a -javaagent in Surefire/Failsafe (see the current Mockito docs).
  • Spring Framework 6.1+ (Boot 3.2+) no longer infers parameter names by parsing bytecode. Keep -parameters on the compiler — the Boot parent already sets this; a custom compiler plugin config can drop it by accident.

5. Tests

Do a full test run after each of the three main steps, not only at the end.

  • Security test configs that extended WebSecurityConfigurerAdapter need the same SecurityFilterChain rewrite.
  • @SpringBootTest plus a changed default security filter can make previously open endpoints require auth in slices you didn't expect.
  • Hibernate 6 can change generated SQL; tests that assert exact SQL or rely on implicit sequences will fail.
  • Recompile test sources too. Stale javax.* imports in src/test are a classic miss.

6. Docker image

Run the app on the same major JDK you compile with. The official Eclipse Temurin images are a solid default:

FROM eclipse-temurin:17-jre-jammy
WORKDIR /app
COPY target/app.jar app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
Enter fullscreen mode Exit fullscreen mode

Use 21-jre-jammy once you move the runtime to 21. Prefer a JRE image for the runtime stage; use a JDK image only in a build stage. Alpine is smaller, but only switch if you've checked native dependencies — some JDBC or libc-sensitive libraries prefer glibc images like Jammy.

If you pass --add-opens today, put those flags in the image entrypoint or your orchestrator JVM options so they don't exist only on a developer's laptop.

7. Rollout and verification

Treat this as a production-risking release, not a library bump.

  1. Staging with production-like data. Compare schemas and a few representative queries before you enable Hibernate to "fix" anything. Watch ID generation and UUID column types especially.
  2. Start up and read the logs. Property-migrator warnings, InaccessibleObjectException, leftover javax ClassNotFoundException, and Flyway or Liquibase failures show up here.
  3. Hit the real paths. Health and readiness, login, the authenticated API, file upload, scheduled jobs, and any SOAP or XML endpoints.
  4. Remove spring-boot-properties-migrator once properties are updated, and drop temporary --add-opens that a library upgrade has made unnecessary.
  5. Canary or blue-green, then watch error rates, GC, and latency. Hibernate 6's SQL can be better, but it is different; a hot query that changed shape is worth a look.
  6. Only then consider Java 21. On Boot 3.2 or later, bump java.version to 21, update the Docker base image, and re-run the same verification. Virtual threads are available from Boot 3.2 with spring.threads.virtual.enabled=true, but that's an optional follow-up, not part of the upgrade itself.

The work is mechanical more than mysterious, as long as you keep the order and verify after each step.

If you'd rather hand this off, I do fixed-scope Java 17/21 and Spring Boot 3 upgrades on Fiverr.

Top comments (0)