Skip to content

Spring Boot with Java 9 and above

Stéphane Nicoll edited this page Nov 20, 2018 · 8 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

Spring Boot 2 is the first version to support Java 9 (Java 8 is also supported). If you are using 1.5 and wish to use Java 9 you should upgrade to 2.0 as we have no plans to support Java 9 on Spring Boot 1.5.x.

Note
Java 10 is supported as of Spring Boot 2.0.1.RELEASE. Java 11 is supported as of Spring Boot 2.1.0.M2. The plan is to officially support Java 12 as of Spring Boot 2.2

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).

Known limitations

These libraries do not have full support for Java 9 yet:

  • Apache Cassandra, see #10453

Clone this wiki locally
You can’t perform that action at this time.