Search code examples
maven-3

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

  • 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.