我正在尝试执行此操作:
mvn archetype:generate -DgroupId=org.sonatype.mavenbook.simple -DartifactId=simple - DpackageName=org.sonatype.mavenbook -Dversion=1.0-SNAPSHOT"
但是它显示了这个错误:
C:\TPMaven>mvn archetype:generate -DgroupId=org.sonatype.mavenbook.simple -DartifactId=simple - DpackageName=org.sonatype.mavenbook -Dversion=1.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.090 s
[INFO] Finished at: 2015-04-20T17:28:05+00:00
[INFO] Final Memory: 5M/108M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\TPMaven). 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]
我的maven声明有什么问题?
答案 0 :(得分:4)
正确的代码应该是:
mvn archetype:generate -DgroupId=org.sonatype.mavenbook.simple -DartifactId=simple -DpackageName=org.sonatype.mavenbook -Dversion=1.0-SNAPSHOT
如果您使用Win,则运行cmd.exe中的上述代码即可。
如果您在PowerShell中运行代码,请使用以下代码:
mvn archetype:generate "-DgroupId=org.sonatype.mavenbook.simple" "-DartifactId=simple" "-DpackageName=org.sonatype.mavenbook" "-Dversion=1.0-SNAPSHOT"
您的代码中有两个错误:
mvn archetype:generate -DgroupId = org.sonatype.mavenbook.simple -DartifactId = simple - DpackageName = org.sonatype.mavenbook -Dversion = 1.0-SNAPSHOT"
- DpackageName
应该是
-DpackageName
-Dversion = 1.0-SNAPSHOT"
应该是
-Dversion=1.0-SNAPSHOT
答案 1 :(得分:0)
您的一个命令行参数之间有一个空格。运行命令:
acanby@PANAMERA /c/projects/mvntest $ mvn archetype:generate -DgroupId=org.sonatype.mavenbook.simple -DartifactId=simple - DpackageName=org.sonatype.mavenbook -Dversion=1.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.072 s
[INFO] Finished at: 2015-04-21T15:20:41+10:00
[INFO] Final Memory: 5M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (c:\projects\mvntest). 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
将- DpackageName=...
部分修复为-DpackageName=...
:
acanby@host /c/projects/mvntest$ mvn archetype:generate -DgroupId=org.sonatype.mavenbook.simple -DartifactId=simple -DpackageName=org.sonatype.mavenbook -Dversion=1.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode