Solucionado (ver solução)

Importante

Você está vendo a versão anterior da nova experiência da Alura que estamos preparando para você. Em breve, ela ganha uma identidade visual novinha totalmente pensada em potencializar seus estudos!

Solucionado
(ver solução)
13
respostas

Erro ao criar um novo projeto(blog).

Quando tento criar o projeto pelo cmder apresenta o seguinte erro: Parace ser algo relacionado ao arquivo pom.xml, não consigo resolver.

C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven
λ mvn archetype:generate -DartifactId=blog -DgroupId=br.com.alura.maven -Dinteractive Mode=false -DarchetypeArtifactId=maven-archetype-quickstart
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.386 s
[INFO] Finished at: 2019-02-20T20:44:32-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven). 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
13 respostas

Aparentemente no diretório que você está executando o comando do maven (C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven), não há nenhum arquivo POM. Você precisa executar este comando no diretório ao qual o POM se encontra.

Não consigo encontrar esse arquivo . Quando tento compilar o projeto apresenta o seguinte aviso:

[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!

Pode me ajudar a resolver isso? Não consigo compilar pelo cmder por conta desses errros.

Isso não seria o motivo do erro ao meu ver, pois é um WARNING do Maven. Você precisa criar um arquivo POM para conseguir compilar o seu projeto maven, pois é pelo arquivo que ele irá compilar baixando as dependências contidas nele.

Este é o código do pom mais básico (crie o arquivo pom.xml no diretorio e tenta executar o maven, depois me diz o que o cmd devolve pra vc):

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>

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

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Aprece o seguinte:

C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven\produtos
λ mvn archetype:generate -DartifactId=blog -DgroupId=br.com.alura.maven -Dinteractive Mode=false -DarchetypeArtifactId=maven-archetype-quickstart
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< br.com.alura.maven:produtos >---------------------
[INFO] Building produtos 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ produtos >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ produtos <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ produtos ---
[INFO] Generating project in Interactive mode
[INFO] Using property: groupId = br.com.alura.maven
[INFO] Using property: artifactId = blog
Define value for property 'version' 1.0-SNAPSHOT: : 1.
[INFO] Using property: package = br.com.alura.maven
Confirm properties configuration:
groupId: br.com.alura.maven
artifactId: blog
version:

Se eu coloco versão pede:

[INFO] Using property: groupId = br.com.alura.maven
[INFO] Using property: artifactId = blog
Define value for property 'version' 1.0-SNAPSHOT: : 1
Define value for property 'package' br.com.alura.maven: : 1
Confirm properties configuration:
groupId: br.com.alura.maven
artifactId: blog
version: 1
package: 1
 Y: :

Fica repetindo as informações.

Preencha Y: : com y

Ele está apenas pedindo sua confirmação para terminar de criar. Acredito que esteja dando certo.

Apresentou outro erro agora

[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven
[INFO] Parameter: package, Value: br.com.alura.maven
[INFO] Parameter: groupId, Value: br.com.alura.maven
[INFO] Parameter: artifactId, Value: blog
[INFO] Parameter: packageName, Value: br.com.alura.maven
[INFO] Parameter: version, Value: 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping my-app
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  29.406 s
[INFO] Finished at: 2019-02-20T21:54:55-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project my-app: Unable to add module to the current project as it is not of packaging type 'pom' -> [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

Antes da tag

 </project>

adicione

<packaging>pom</packaging> 

Deu erro porque coloquei a tag packaging.

C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven
λ mvn archetype:generate -DartifactId=blog -DgroupId=br.com.alura.maven -Dinteractive Mode=false -DarchetypeArtifactId=maven-archetype-quickstart
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven\pom.xml: Expected root element 'project' but found 'packaging' (position: START_TAG seen <packaging>... @1:11)  @ line 1, column 11
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project  (C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven\pom.xml) has 1 error
[ERROR]     Non-parseable POM C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven\pom.xml: Expected root element 'project' but found 'packaging' (position: START_TAG seen <packaging>... @1:11)  @ line 1, column 11 -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

Talvez vc tenha colocado essa tag fora do project... tenta colocar nessa estrutura aqui, por favor:

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>

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

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
<packaging>pom</packaging> 
</project>

É um erro atrás do outro, vou tentar esvaziar a pasta .m2/repository pra ver se da certo.

C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven
λ mvn archetype:generate -DartifactId=blog -DgroupId=br.com.alura.maven -Dinteractive Mode=false -DarchetypeArtifactId=maven-archetype-quickstart
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ my-app >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ my-app <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ my-app ---
[INFO] Generating project in Interactive mode
[INFO] Using property: groupId = br.com.alura.maven
[INFO] Using property: artifactId = blog
Define value for property 'version' 1.0-SNAPSHOT: : 1
[INFO] Using property: package = br.com.alura.maven
Confirm properties configuration:
groupId: br.com.alura.maven
artifactId: blog
version: 1
package: br.com.alura.maven
 Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven
[INFO] Parameter: package, Value: br.com.alura.maven
[INFO] Parameter: groupId, Value: br.com.alura.maven
[INFO] Parameter: artifactId, Value: blog
[INFO] Parameter: packageName, Value: br.com.alura.maven
[INFO] Parameter: version, Value: 1
[INFO] project created from Old (1.x) Archetype in dir: C:\Users\Jean\Desktop\Alura\Cursos Alura\Java\Java Maven\blog
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  44.930 s
[INFO] Finished at: 2019-02-20T22:11:30-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "Mode=false". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/LifecyclePhaseNotFoundException
solução!

Consegui resolver.

Primeiro inseri o comando abaixo na pasta do projeto

mvn clean verify

Depois:

mvn install

Assim consegui criar o projeto.

Obrigado pela ajuda Raquel Natali Mariz!

De nada, fico feliz por vc ter conseguido. :)