Maven: Invalid target release: 10

Same problem fixed for me by setting JAVA_HOME environment variable to point to the JDK with right version.

My source and destination java version in maven-compiler-plugin were 11, java -version was also on version 11, but my JAVA_HOME was pointing to JDK-1.8.

Check JAVA_HOME again by using a terminal instead of IDE:

Linux:
echo $JAVA_HOME

Win:
echo %JAVA_HOME%

Then Build your project in the same terminal:

mvn clean package

This worked for me:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <release>10</release>
            </configuration>
        </plugin>
    </plugins>
</build>

This answer says you need:

<dependencies>
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>6.2</version> <!-- Use newer version of ASM -->
    </dependency>
</dependencies>

inside the <plugin/> tag, but the newer mvn (3.5.4) must obviate that, since I didn't need it.


Get your java version by running java -version.

You'll get a output like :

java version "1.8.0_201"

Now go to your POM file and update source and target properities of maven-compiler-plugin with your installed java version. In my case it's 1.8

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
      <source>1.8</source>
      <target>1.8</target>
   </configuration>
</plugin>

I had a similar problem with spring boot and java 11. I solved it by defining the following property in my pom

<maven.compiler.release>11</maven.compiler.release>

Might be useful for someone in the future.