Unable to Compile Simple Java 10/Java 11 Project with Maven
This issue arises when attempting to build a project using Java 10 or 11 in conjunction with Maven. Despite specifying a release value of "10" for the maven-compiler-plugin's configuration, the build fails.
Cause:
The failure is caused by an incompatibility between the Maven compiler plugin and the Java version used during compilation. The plugin used in the provided example (3.7.0) does not support explicitly specifying a Java release version.
Solution:
To resolve this issue, it is necessary to upgrade the maven-compiler-plugin to version 3.8.0. This upgraded plugin supports specifying a release value for Java versions 9, 10, and 11.
Updated pom.xml:
... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>10</release> </configuration> </plugin> ...
Important Note:
The above is the detailed content of Why Does My Maven Java 10/11 Project Fail to Compile, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!