为什么不使用archetype:带参数的生成对我有用?

时间:2013-06-30 00:10:18

标签: maven maven-3 maven-plugin gwt-maven-plugin

如果我运行mvn archetype:生成它有效,但如果我尝试

mvn archetype:generate -DarchetypeGroupId org.codehaus.mojo -DarchetypeArtifactId gwt-maven-plugin  -DarchetypeVersion=2.5.0 

该消息来自我上次使用反斜杠的尝试,但它是相同的消息,没有斜杠命令

E:\mavenplay\a>mvn archetype:generate \ -DarchetypeGroupId org.codehaus.mojo \ -
DarchetypeArtifactId gwt-maven-plugin \ -DarchetypeVersion=2.5.0 -X
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 15:51:
28+0200)
Maven home: E:\apache-maven-3.0.5\bin\..
Java version: 1.6.0_25, vendor: Sun Microsystems Inc.
Java home: E:\Program Files\Java\jdk1.6.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from E:\apache-maven-3.0.5\bin\..\conf\settings.
xml
[DEBUG] Reading user settings from C:\Users\henkel\.m2\settings.xml
[DEBUG] Using local repository at C:\Users\henkel\.m2\repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for C:\Use
rs\henkel\.m2\repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (non
e)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.co
re, parent: null]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.247s
[INFO] Finished at: Sun Jun 30 03:00:22 EEST 2013
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
 in this directory (E:\mavenplay\a). Please verify you invoked Maven from the co
rrect directory. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requi
res a project to execute but there is no POM in this directory (E:\mavenplay\a).
 Please verify you invoked Maven from the correct directory.
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:89)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
[ERROR]
[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
E:\mavenplay\a>

我尝试使用/ \而不是削减。请
 让我知道其他细节。

LE:作为旁注,我确实设法以交互模式创建了原型,但我只是好奇为什么它不能直接起作用

5 个答案:

答案 0 :(得分:27)

如果您使用的是Windows shell,则需要在这些参数周围加上引号:

mvn archetype:generate "-DarchetypeGroupId=org.codehaus.mojo" "-DarchetypeArtifactId=gwt-maven-plugin" "-DarchetypeVersion=2.5.0"

感谢海报here指出这一点。

答案 1 :(得分:8)

某些参数缺少=个标志,请尝试:

 mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.5.0

您也可以指定-DgroupId=<group-id>-DartifactId=<artifact-id>,以便Maven不会问。

答案 2 :(得分:0)

我在Windows 7上遇到了同样的问题。我的解决方案是确保Maven bin子目录的路径明确是路径上的第一件事。我认为Maven正在从其可执行文件的路径中获取其配置目录的路径,并且我的路径上的某些内容指向另一个版本的Maven(我不确定具有什么或哪里)具有无效配置。

因此,尝试修改PATH以将mvn可执行文件的正确路径作为第一项,并查看这是否为您修复了这些内容。

答案 3 :(得分:0)

我在linux上面临着同样的问题。碰巧我在=符号的两边都有空格。删除这些空格即可正常工作。

答案 4 :(得分:0)

在CMD中编写代码时,请尝试在':'冒号之前或之后写任何空格

这样写-mvn archetype:generate