I am trying to start with Spring-boot, Maven in Intellij Please help me I am getting the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project spring-rest: Fatal error compiling: invalid flag: --release -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Process finished with exit code 1
My pom.xml is:
<?xml version="1.0" encoding="UTF-8"?> <project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>spring-rest</artifactId>
<version>3.1.3.RELEASE</version>
<packaging>war</packaging>
<name>spring-rest</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>8</release>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
</project>
This has to do with the version of JDK running on your system. As per the documentation for maven-compiler-plugin, the release flag is supported since 1.9, and thus has to be commented/removed from the POM if you are using prior (1.8 and below) versions of JDK. Show activity on this post.
(IntelliJ version 2019.1) java.version is 11, declared in the properties part of the pom.xml. Maven version should be 3.6 or higher.
Open a prompt command and execute the following command: The JAVA_HOME points to a JDK 1.6 and this is why Maven throws the exception: invalid target release. You must set the value of JAVA_HOME to the correct JDK 1.7 home directory. Below how to perform it:
In your pom.xml file, simply remove the tag <release>8</release> from your maven-compiler-plugin configuration: Show activity on this post. This has to do with the version of JDK running on your system.
In your pom.xml
file, simply remove the tag <release>8</release>
from your maven-compiler-plugin
configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
</configuration>
</plugin>
This has to do with the version of JDK running on your system. As per the documentation for maven-compiler-plugin, the release flag is supported since 1.9, and thus has to be commented/removed from the POM if you are using prior (1.8 and below) versions of JDK.
Check Maven documentation for release tag for maven-compiler-plugin here
I faced this problem too, check your JAVA_HOME environment variable. I was setting the value of release to 11 as I am using JAVA 11. My System JAVA_HOME was set for java 8, After adding the JAVA_HOME user environment variable to the java 11 path this got resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With