2
respostas

mvn package com erro de compilação [ERROR] Source option 5 is no longer supported. Use 7 or later.

Olá pessoal!

Estou enfrentando o seguinte problema na tentativa de criar o jar da aplicação:

C:\Users\ezribjo\eclipse-workspace\listavip>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< br.com.boot.listavip:listavip >--------------------
[INFO] Building listavip 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ listavip ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 23 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ listavip ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 5 source files to C:\Users\ezribjo\eclipse-workspace\listavip\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.125 s
[INFO] Finished at: 2020-03-25T16:53:52-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project listavip: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[ERROR] -> [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/MojoFailureException

O erro:

[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.

Já tentei mudar a versão no Pom mas de nada adiantou.

Obrigado!

2 respostas

Oi João

Você provavelmente está usando uma versão mais nova do JDK. Utilize o JDK 8 para esse projeto, deve resolver.

Oi Otávio, Alterei no Properties - > Java Build Path -> Libraries do projeto mas não mudou muita coisa. Forcei a versão do compiler do Maven no pom e parece que o problema foi solucionado:

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

Porém, encontrei outro problema:

C:\Users\ezribjo\eclipse-workspace\listavip>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< br.com.boot.listavip:listavip >--------------------
[INFO] Building listavip 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ listavip ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 23 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ listavip ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 5 source files to C:\Users\ezribjo\eclipse-workspace\listavip\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/ezribjo/eclipse-workspace/listavip/src/main/java/br/com/boot/listavip/ConvidadoController.java:[10,42] package br.com.boot.emailSender.gmailBased does not exist
[ERROR] /C:/Users/ezribjo/eclipse-workspace/listavip/src/main/java/br/com/boot/listavip/ConvidadoController.java:[45,21] cannot find symbol
  symbol:   class EmailService
  location: class br.com.boot.listavip.ConvidadoController
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.572 s
[INFO] Finished at: 2020-03-26T11:37:45-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project listavip: Compilation failure: Compilation failure:
[ERROR] /C:/Users/ezribjo/eclipse-workspace/listavip/src/main/java/br/com/boot/listavip/ConvidadoController.java:[10,42] package br.com.boot.emailSender.gmailBased does not exist
[ERROR] /C:/Users/ezribjo/eclipse-workspace/listavip/src/main/java/br/com/boot/listavip/ConvidadoController.java:[45,21] cannot find symbol
[ERROR]   symbol:   class EmailService
[ERROR]   location: class br.com.boot.listavip.ConvidadoController
[ERROR] -> [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/MojoFailureException

Erro:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project listavip: Compilation failure: Compilation failure:
[ERROR] /C:/Users/ezribjo/eclipse-workspace/listavip/src/main/java/br/com/boot/listavip/ConvidadoController.java:[10,42] package br.com.boot.emailSender.gmailBased does not exist
[ERROR] /C:/Users/ezribjo/eclipse-workspace/listavip/src/main/java/br/com/boot/listavip/ConvidadoController.java:[45,21] cannot find symbol
[ERROR]   symbol:   class EmailService
[ERROR]   location: class br.com.boot.listavip.ConvidadoController

Essa classe EmailService é de outro projeto que tentei transformar numa lib e importar pela pom.xml:

    <dependency>
            <groupId>br.com.boot.emailSender</groupId>
            <artifactId>gmailBased</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

Apesar do projeto EmailSender estar no repositório e ter sido importado para o path do Eclipse pela pom do Maven, só é possível utilizá-lo/importá-lo em uma classe quando o projeto do EmailSender está devidamente aberto. Assim que clico em "Close Project" a classe perde a referência.

Caso seja mais adequado a abertura de outro tópico, é só falar. Agradeço o tempo e atenção!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software