1
resposta

Não é possível compilar projeto "produtos" criado pela Maven

O projeto é criado com sucesso através do comando "mvn archetype:generate -DartifactId=produtos -DgroupId=br.com.alura.maven -DinteractiveMode=false -DarchetypeArtifactId=maven-archetype-quickstart", porém ao executar a compilação "mvn compile" o seguinte erro é exibido:

C:\Users\adelm\eclipse-workspace\alura\maven\produtos>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< br.com.alura.maven:produtos >---------------------
[INFO] Building produtos 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ produtos ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\adelm\eclipse-workspace\alura\maven\produtos\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ produtos ---
[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 1 source file to C:\Users\adelm\eclipse-workspace\alura\maven\produtos\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.641 s
[INFO] Finished at: 2020-03-01T16:07:55-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project produtos: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[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

Vi que nos postos do curso alguém passou pelo mesmo problema e a solução foi ir no Eclipse-> Window -> Preferences -> Java -> Installed JREs e alterar o caminho para a pasta JDK. Fiz este procedimento, mas não fucionou. Estava jre1.8.0_201, alterei para jdk1.8.0_201.

1 resposta

Bom dia Adelmo, tudo bem?

Como está a sua variável de ambiente JAVA_HOME? Está apontando para a jdk?

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