Minimum Spring Version Compatible with Java 11

Minimum Spring version compatible with Java 11

From their task tracker -- SPR-16391:Compatibility with JDK 11. The compatibility of JDK 10, 11 is planned along with 5.1 GA release.

JDK 11 is currently scheduled for September 2018. Not expecting any
major changes beyond JDK 10 from our perspective, we should be able to
fully support it in the 5.1 line already.

Ideally our framework build would be able to run on JDK 8, 9, 10 as
well as 11, even if our own test efforts will focus on JDK 8 and 11
(as the official long-term support branches) at that point.

While the option of experimenting with your own code on module path is still feasible using spring framework 5.0, which provides out-of-the-box support for JDK 9 already.

Update: Spring Framework 5.1 goes GA on 21st September, 2018

Minimum Spring-batch and spring-context version compatible with Java 11?

I know the Spring version should be at least 5.1

<org.springframework.batch>2.1.9.RELEASE</org.springframework.batch>

You seem to be upgrading Spring Batch from v2. Since your Spring version should be at least v5.1, you need to upgrade Spring Batch to v4 (which is based on Spring Framework v5) and requires Java 8 at a minimum. So the answer to your question about the minimum Java version is Java 8, but you should be able to use Java 11 if you want.

Spring 4.3.x with OpenJDK 11

The big jump in terms of incompatibility came with the move from 8 to 9.

You can see the tickets the Spring team had to complete to make Spring compatible with JDK 9 by using their public JIRA issue system and looking at the jdk9/java9 labels.

For the remaining Java 11 issues, you could look at a text search for Java 11.

How to specify Java version in Spring/Spring Boot pom.xml?

Short Answer:

The correct way is to use the followings values in <java.version> for different Java versions:

  • Java 8 : 1.8 or 8
  • Java 9 : 9
  • Java 10 : 10
  • Java 11 : 11
  • Java 12 : 12
  • .....
  • .....
  • Java 17 : 17
  • Java 18 : 18
  • Java 19 : 19

So for Java 11 , it should be:

<properties>
<java.version>11</java.version>
</properties>

However I'm not sure if Java 11 would be "1.11" (seems unlikely), and
I've seen it specified as just "11" when using maven-compiler-plugin,
however I'm not using the compiler plugin.

Actually , at the end it still uses maven-compiler-plugin to compile. Springboot just configures a <java.version> property such that by changing this value , you are implicitly changing maven-compiler-plugin 's <source/> and <target/> to the same value as what specified in the <java.version> :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source> <!-- same as <java.version> -->
<target>11</target> <!-- same as <java.version> -->
</configuration>
</plugin>

Detailed Answer:

Seem like you want details to convince you.

It is because every spring boot project will extend the parent pom spring-boot-starter-parent which defines <java.version> as follows:

<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>

From the maven-compiler-plugin docs, maven.compiler.source and maven.compiler.target are the user property for the <source> and <target> config parameters. Due to the behaviour of the user property, setting these two properties to 11 means to set the following :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source> <!-- maven.compiler.source -->
<target>11</target> <!-- maven.compiler.target -->
</configuration>
</plugin>

From the maven-compiler-plugin docs again, <source> and <target> are the -source and -target argument for the Java compiler (javac). Then, from javac docs, we can see that these two arguments are allowed to have the following values:

  • 1.6 : No language changes were introduced in Java SE 6. However, encoding errors in source files are now reported as errors instead of
    warnings as was done in earlier releases of Java Platform, Standard Edition.
  • 6 : Synonym for 1.6.
  • 1.7 : The compiler accepts code with features introduced in Java SE 7.
  • 7 : Synonym for 1.7.
  • 1.8 : The compiler accepts code with features introduced in Java SE 8.
  • 8 : Synonym for 1.8.
  • 9 : The compiler accepts code with features introduced in Java SE 9.
  • 10 : The compiler accepts code with features introduced in Java SE 10.
  • 11 : The compiler accepts code with features introduced in Java SE 11.
  • 12 : The compiler accepts code with features introduced in Java SE 12.

Hence, <java.version> should be set to 11 for Java 11.



Related Topics



Leave a reply



Submit