Reputation: 81
I want to build project and it give error like this:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project messaging-utils-core: Fatal error compiling: invalid target release: 11
I've tried to fix in various way by Googling it up but it doesn't work in my local. I am using Eclipse.
Here is how my pom.xml looks like:
<?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">
<parent>
<groupId>sg.com.nets.utils</groupId>
<artifactId>messaging-utils-parent</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>messaging-utils-core</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>sg.com.nets.common.faulttolerance</groupId>
<artifactId>fault-tolerance-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jcsmp</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
</dependency>
</dependencies>
I run mvn --version and it give this:
Apache Maven 3.6.3
Java version: 1.8.0_281
For my environment I have this:
JAVA_HOME = D:\pathlocation\jdk1.8.0_281
Please assist me as I try to fix this issue several days already and still haven't solve. Thank you.
Upvotes: 6
Views: 46456
Reputation: 489
In my case:
I had installed java 8 and 17 both on local environment.
but I forgot to update JAVA_HOME
to JDK 17,
And JAVA IDE was compiling project at JDK 8
thats why i was getting this error.
once i update JAVA_HOME
to JDK 17 installed path in environment variables. i was able to resolve this issue.
#jdk8 #jdk17 #springboot2.3 #maven #compilingerrors
Upvotes: 2
Reputation: 1
I fixed by adding this:
<properties>
<java.version>8</java.version>
</properties>
In the POM.xml file
Upvotes: 0
Reputation: 81
I have fixed the issue already. I just add this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Upvotes: 2
Reputation: 35815
You are trying to build a project for Java 11 with JDK 8.
So you need to use a newer JDK.
Upvotes: 1