Problema para dar Build no maven

Criei um projeto no Maven e ao tentar dar build nele esbarrei no seguinte erro.
Já tentei mudar a variavel jdk, dei clean, test e install no projeto e dei um update no Maven, mas nada disso resolveu.

Vocês já esbarram nesse problema?

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Felipe%20Lima/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/Users/Felipe%20Lima/eclipse/java-2020-12/eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Felipe%20Lima/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/Users/Felipe%20Lima/eclipse/java-2020-12/eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< br.com.clarobr:equipments >----------------------
[INFO] Building equipments 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.5:prepare-agent (jacoco-prepare-agent) @ equipments ---
[INFO] argLine set to "-javaagent:C:\\Users\\Felipe Lima\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.5\\org.jacoco.agent-0.8.5-runtime.jar=destfile=C:\\Users\\Felipe Lima\\Desktop\\Nova pasta (2)\\equipments\\target\\jacoco.exec,excludes=**/config/**:**/error/**:**/exception/**:**/correlation/**:**/observability/**:**/test/**:**/models/**:**/*Application.java:pom.xml"
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ equipments ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ equipments ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 25 source files to C:\Users\Felipe Lima\Desktop\Nova pasta (2)\equipments\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:  3.546 s
[INFO] Finished at: 2021-08-03T14:45:41-03:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project equipments: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[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

Se tu fizer um mvn --version o que ele te retorna?

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Maven\apache-maven-3.8.1\bin\..
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_191\jre
Default locale: pt_BR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Agora, quando eu faço a build aparece a seguinte mensagem:

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< br.com.clarobr:equipments >----------------------
[INFO] Building equipments 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.5:prepare-agent (jacoco-prepare-agent) @ equipments ---
[INFO] argLine set to "-javaagent:C:\\Users\\Felipe Lima\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.5\\org.jacoco.agent-0.8.5-runtime.jar=destfile=C:\\Users\\Felipe Lima\\Desktop\\Nova pasta (2)\\equipments\\target\\jacoco.exec,excludes=**/config/**:**/error/**:**/exception/**:**/correlation/**:**/observability/**:**/test/**:**/models/**:**/*Application.java:pom.xml"
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ equipments ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ equipments ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 25 source files to C:\Users\Felipe Lima\Desktop\Nova pasta (2)\equipments\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:  3.062 s
[INFO] Finished at: 2021-08-03T14:57:21-03:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project equipments: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[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

Esse erro geralmente acontece quando a configuração do java está incorreta.

Como estão configuradas suas variáveis de ambiente JAVA_HOME e PATH?

Reparei que vc tem 2 builds diferentes para mesma versão do java configuradas no JAVA_HOME: jdk1.8.0_191 e jdk1.8.0_271.

Tente deixar apenas essa versão: jdk1.8.0_271 (remova o JAVA_HOME específico do seu usuário).

1 curtida

Como faz tempo que não mexo com Windows eu não me recordo se ele segue uma ordem de precedência, como você tem duas JAVA_HOME configuradas, um para usuário e outra para sistema, talvez estejam conflitando quando o maven tenta utilizar.

Quando eu utilizava Windows eu definia somente a de sistema, afinal, só tinha meu usuário na máquina que eu utilizava.

1 curtida

Mas o estranho é porque outros projetos do Maven rodam. E além disso, como o pc é da empresa, eu não consigo tirar a variavel do sistema, pois os projetos precisam daquela versão especifica do java (8 1.191), por isso eu instalei ele… Mas vou tentar desinstalar a do administrador

Se tu fizer o inverso não é mais simples?

Apagar a de usuário e alterar o valor da de sistema para apontar para o JDK 8 1.191?

Estranho outros projetos funcionarem, imagino que isso seria um problema comum independentemente de projeto :thinking: