1
resposta

Erro ao compilar no maven

Ao executar o comando mvn compile no prompt de comando, ainda que no diretório correto, sempre retorna este erro:

C:\Users\KAMILLA>mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.108 s
[INFO] Finished at: 2019-12-10T21:42:48-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\KAMILLA). Please verify you invoked Maven from the correct directory. -> [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/MissingProjectException

C:\Users\KAMILLA>

já tentei alterar as configuralções do pom.xml como sugerido a outro colega, mas não funcionou. Segue o código dentro do pom.xml gerado pelo build do maven:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>br.com.alura.maven</groupId>
  <artifactId>produtos</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>produtos</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Os comandos do prompt ao total foram os seguintes:

C:\Users\KAMILLA>dir produtos
 O volume na unidade C não tem nome.
 O Número de Série do Volume é DA64-2E8A

 Pasta de C:\Users\KAMILLA\produtos

10/12/2019  21:27    <DIR>          .
10/12/2019  21:27    <DIR>          ..
10/12/2019  21:27               665 pom.xml
10/12/2019  21:27    <DIR>          src
               1 arquivo(s)            665 bytes
               3 pasta(s)   145.080.573.952 bytes disponíveis

C:\Users\KAMILLA>mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.119 s
[INFO] Finished at: 2019-12-10T21:39:15-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\KAMILLA). Please verify you invoked Maven from the correct directory. -> [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/MissingProjectException
1 resposta

Você está tentando executar o mvn no diretório C:\Users\KAMILLA>mvn compile mas o seu pom.xml está em C:\Users\KAMILLA\produtos

do diretório Kamilla faça um cd produtos e depois pode executar normalmente.

ou faz cd C:\Users\KAMILLA\produtos

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