Skip to content

Spring Boot with Java 9 and above

Andy Wilkinson edited this page Nov 6, 2025 · 13 revisions

This page gathers the things that you need to know if you want to run Spring Boot apps on Java 9 and above.

Requirements

Refer to the system requirements of the reference guide to know if your target Java version is supported. Make sure you use the versioned URL that matches the Spring Boot generation you are using.

Java 25 specific

Java 25 introduced a number of new restrictions that can lead to warnings being produced at runtime. The warnings are written to System.err, each line beginning with WARNING:. For example:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper (file:/…/guava-33.2.1-jre.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by org.fusesource.hawtjni.runtime.Library in an unnamed module (file:/Users/aw036093/dev/spring-projects/spring-boot/main/build-plugin/spring-boot-maven-plugin/build/maven-binaries/apache-maven-3.6.3/lib/jansi-1.17.1.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

These are not necessarily bugs and, unless the package of an offending class begins with org.springframework.boot, cannot be addressed in Spring Boot itself. Where a corrective action is available, such as starting the JVM with --enable-native-access=ALL-UNNAMED, it will appear in the warning message. Before reporting an issue to the maintainers of a particular class, please search their issue tracker for an existing report. It is likely that the maintainers are already aware.

Java 17 specific

Kotlin

Kotlin 1.5.x does not support Java 17.

Gradle

You need Gradle 7.2 or later to use it with Java 17. If you can’t upgrade you can use Gradle’s toolchain support to build your project with Java 17.

Java 16 specific

Spring LDAP

Spring LDAP 2.3.3 and earlier requires --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED.

Spring Boot CLI

The Spring Boot CLI does not work with Spring Boot 2.4.x as it still uses Groovy 2.5.x.

Groovy

Java 16 requires Groovy 3.x. You may need to override the version using groovy.version.

Gradle

Gradle does not yet support Java 16. Gradle projects that wish to use Java 16 should use Gradle’s toolchain support to do so.

Illegal access

Some components which Spring Boot can auto-configure, such as Hazelcast, require --illegal-access=warn.

Kotlin

Kotlin does not yet support Java 16.

Previous Java generations (Java 9 - 15)

AspectJ

With Java 9, if you need to weave classes from the JDK, you need to use AspectJ 1.9. Spring AOP should work fine in most cases with AspectJ 1.8 (the default in Spring Boot 2.0).

JAXB

When upgrading you may face the following:

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Hibernate typically requires JAXB that’s no longer provided by default. You can add the java.xml.bind module to restore this functionality with Java9 or Java10 (even if the module is deprecated).

As of Java11, the module is not available so your only option is to add the JAXB RI (you can do that as of Java9 in place of adding the java.xml.bind module:

<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
</dependency>

Lombok

If you are using lombok, the managed version of Spring Boot may not work with the latest JDK. Check the Lombok web site and override its version if necessary.

Reflection APIs and WildFly

When deployed as a WAR application on WildFly, Spring Boot applications might require some advanced JDK reflection API for proxying, included in the sun.reflect package. For that, your application needs to list jdk.unsupported as a Dependency in its MANIFEST.MF file (see the WildFly wiki about this).

Clone this wiki locally