-
Notifications
You must be signed in to change notification settings - Fork 40.7k
Spring Boot with Java 9 and above
This page gathers the things that you need to know if you want to run Spring Boot apps on Java 9 and above.
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.
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.
Spring LDAP 2.3.3
and earlier requires --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
.
The Spring Boot CLI does not work with Spring Boot 2.4.x
as it still uses Groovy 2.5.x
.
Gradle does not yet support Java 16. Gradle projects that wish to use Java 16 should use Gradle’s toolchain support to do so.
Some components which Spring Boot can auto-configure, such as Hazelcast, require --illegal-access=warn
.
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).
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>
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.
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).