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:
$ java -version openjdk version "11" 2018-09-25 OpenJDK Runtime Environment 18.9 (build 11+28) OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
Make sure that you have the matching compiler, check out its version with the following command:
$ javac -version javac 11
It’s also important to double-check the Maven configuration:
$ mvn --version Apache Maven 3.5.2 Maven home: /usr/share/maven Java version: 11, vendor: Oracle Corporation Java home: /usr/lib/jvm/jdk-11 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.15.0-43-generic", arch: "amd64", family: "unix"
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:
Additionally, you can go to File → Settings → Build, Execution, Deployment
and verify the Maven Runner
settings:
and Java Compiler
settings:
Clean the files and directories generated by Maven during the failed build and compile your project again either with the
$ mvn clean install
command or directly in the IntelliJ UI.
Photo by Clem Onojeghuo on StockSnap
Spring Security allows us to use role-based control to restrict access to API resources. However,…
A custom annotation in Spring Boot tests is an easy and flexible way to provide…
Delegating user management to Keycloak allows us to better focus on meeting the business needs…
Swagger offers various methods to authorize requests to our Keycloak secured API. I'll show you…
Configuring our Spring Boot API to use Keycloak as an authentication and authorization server can…
Keycloak provides simple integration with Spring applications. As a result, we can easily configure our…