When updating to
Java 11 from an older version of the language, make sure that your development environment is up to date. Otherwise you will receive the
"Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project: Fatal error compiling: invalid target release: 11"
error while building a project with Maven. Follow the checklist in this post to adjust the required settings for building a Spring Boot application.
Have you installed the appropriate JDK? Run this command to verify which version will be used:
Make sure that you have the matching compiler, check out its version with the following command:
It’s also important to double-check the Maven configuration:
The output of the above command reveals not only the version of Maven currently installed on your machine, but also the value of the JAVA_HOME variable and the Java version used by the tool.
The fatal compilation error can also occur if you compile projects through your IDE interface without updating its settings.
To verify the settings you need to go to
File → Project Structure and check the
Project SDK and
Project Language Level. If the JDK for Java 11 is missing, you can add it by clicking the
New… button, selecting
+JDK and choosing the proper directory in the
Select Home Directory for JDK window:
Furthermore, verify the
Language level for
Modules in your project:
Java Compiler and Maven Runner
Additionally, you can go to
File → Settings → Build, Execution, Deployment and verify the
Maven Runner settings:
Java Compiler settings:
Compile your project
Clean the files and directories generated by Maven during the failed build and compile your project again either with the
command or directly in the IntelliJ UI.