Error - Java Maven Does Not Build - Release Version Not Supported

Asked

Viewed 100 times

0

Good afternoon, everyone,

I installed intellij alone in Ubuntu version 18.4. I need to do a Maven project. I did a test, created the project and in a class to make a simple Hello world. However only appears this photo error and does not return the Hello world, someone could help me ?

Thank you [Error that appears on the screen this in the image]

inserir a descrição da imagem aqui

  • 2

    Post the code in text format and if possible put the error also ,I suggest you read https://pt.meta.stackoverflow.com/questions/8089/guia-survivor%C3%aancia-do-sopt-vers%C3%a3o-short? cb=1 and edit your post so it won’t be closed.

1 answer

6


The problem is in the version of Java you are using for the compilation in Maven.

You can fix this in two ways:

<plugins>
    <plugin>    
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.8</source> <!-- Identificar a versão desejada aqui -->
            <target>1.8</target>
        </configuration>
    </plugin>
</plugins>

Or:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

These instructions above are equivalent.

I also suggest using the latest available version of the plugin, currently is the 3.8.1.


Starting from Java 9, you must use release instead of source and target, as below:

<plugins>
    <plugin>    
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <release>11</release>
        </configuration>
    </plugin>
</plugins>

If you are using Spring Boot, you can only identify the version of Java through the property java.version:

<properties>
    <java.version>11</java.version>
</properties>
  • thank you so much for your help :)

  • good that it worked @Fabícanedoyugar :) do not forget to mark the answer as accepted and give upvote :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.