我正在关注maven教程。我正在尝试执行这个命令,这是我的第一个maven命令。教程说它会创建一个名为my-app的目录,但事实并非如此。这是命令&它的输出, 命令:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
输出:
C:\Users\Babar>mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=m
y-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Batch mode
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
maven-archetype-quickstart:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.mycompany.app
[INFO] Parameter: packageName, Value: com.mycompany.app
[INFO] Parameter: package, Value: com.mycompany.app
[INFO] Parameter: artifactId, Value: my-app
[INFO] Parameter: basedir, Value: C:\Users\Babar
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.971s
[INFO] Finished at: Fri Nov 18 00:07:12 EET 2011
[INFO] Final Memory: 6M/11M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.1:generate (default-cli) on project standalone-pom: Directory my-app already ex
ists - please run from a clean 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/MojoFailureExc
eption
'cmd' is not recognized as an internal or external command,
operable program or batch file.
错误消息说目录已经存在,但事实并非如此。我执行此命令比oncw
更多修改
命令(建议回答)
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archet
ypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPS
HOT
输出
C:\Users\Babar>mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archet
ypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPS
HOT
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [org.apache.maven.archet
ypes:maven-archetype-quickstart:1.1] found in catalog remote
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.552s
[INFO] Finished at: Fri Nov 18 01:09:15 EET 2011
[INFO] Final Memory: 6M/12M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.1:generate (default-cli) on project standalone-pom: The desired archetype does
not exist (org.apache.maven.archetypes:maven-archetype-quickstart:5-SNAPSHOT) ->
[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/MojoFailureExc
eption
'cmd' is not recognized as an internal or external command,
operable program or batch file.
答案 0 :(得分:1)
试试这个:
mvn archetype:generate -DgroupId="com.mycompany.app" -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
您的句子已被修改-DgroupId="com.mycompany.app"
。你需要使用双引号。
我曾在Windows 8上工作,但它确实有效。我不知道它是否发生在Linux上。
答案 1 :(得分:1)
尝试这个,它适用于win7 32位的maven 3-3-9
mvn archetype:generate -DgroupId="com.mycompany.app" -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
答案 2 :(得分:1)
答案 3 :(得分:0)
这条线值得关注:
[INFO]使用以下参数从Old(1.x)创建项目 原型:maven-archetype-quickstart:1.0
查看http://maven.apache.org/archetype/maven-archetype-bundles/maven-archetype-quickstart/处的maven文档页面,我看到您应该使用的命令是:
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPSHOT
这与你正在运行的不完全相同(你缺少-DarchetypeVersion = 5-SNAPSHOT部分)。
答案 4 :(得分:0)
你会注意到原来的错误说
目录my-app已经存在 - 请从干净的目录
运行
您是否可以从已存在Maven项目的目录(具有pom.xml
文件的项目)中运行该命令?如果是这样,请从干净的位置开始。
当我运行命令时,您在空目录上使用了 verbatim ,它运行时没有错误,并创建了一个名为my-app
的目录。