'Why mvn archetype does not work for me?

I'm new on Maven and there's something wrong when I try to create a now project.

E:\java\MavenTest>mvn archetype:generate -DgroupId=com.mycompany.app -DartifacId
=my_app -DarchetypeArtifacId = maven_archetype_quickstart -DinteractiveMode=fals
e
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.108s
[INFO] Finished at: Wed May 15 23:55:57 CST 2013
[INFO] Final Memory: 7M/76M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
 in this directory (E:\java\MavenTest). 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 swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProject
Exception

The pom.xml should be generated automatically. But it does not work.

Any help will be highly appreciated.



Solution 1:[1]

The root cause are as the following: -

  1. There is a space at -DarchetypeArtifacId = maven_archetype_quickstart
  2. The archetypeArtifacId should be maven-archetype-quickstart
  3. The -DarchetypeArtifacId is miss spelling, the correct is -DarchetypeArtifactId

Then please try the following: -

mvn archetype:generate 
    -DgroupId=com.mycompany.app 
    -DartifactId=my_app 
    -DarchetypeGroupId=org.apache.maven.archetypes 
    -DarchetypeArtifacId=maven-archetype-quickstart 
    -DarchetypeVersion=1.1 
    -DinteractiveMode=false

Please type above command in the single line.

I hope this may help.

Solution 2:[2]

Another answer will be related to the console that you are using to generate the maven project with the archetype:

For example: With Powershell, the command of the answer doesn't work but with this command is working properly

mvn archetype:generate 
    "-DgroupId=com.mycompany.app 
    -DartifactId=my_app 
    -DarchetypeGroupId=org.apache.maven.archetypes 
    -DarchetypeArtifacId=maven-archetype-quickstart 
    -DarchetypeVersion=1.1 
    -DinteractiveMode=false"

because of the problems passing the arguments to the maven command.

This is gonna help somebody, it works for me!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Charlee Chitsuk
Solution 2 Josue Rojas Vega