16

如果我运行 mvn archetype:generate 它可以工作,但如果我尝试

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:作为旁注,我确实设法在交互模式下创建原型,但我只是好奇为什么它不能直接工作

4

5 回答 5

79

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

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

感谢这里的海报指出这一点。

于 2015-07-06T03:28:59.720 回答
12

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

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

你也可以指定-DgroupId=<group-id>-DartifactId=<artifact-id>这样 Maven 就不会问了。

于 2013-06-30T00:18:18.467 回答
0

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

因此,请尝试修改您的 PATH 以将 mvn 可执行文件的正确路径作为第一项,看看这是否为您解决了问题。

于 2014-05-19T13:32:30.797 回答
0

我在linux上遇到了同样的问题。碰巧我在 = 符号的两边都有空格。删除这些空格使其工作。

于 2018-11-19T17:11:02.223 回答
0

当您在 CMD 中编写它时,请尝试在 ':' 冒号之前或之后不带任何空格来编写它

像这样写 - mvn archetype:generate

于 2020-01-24T20:15:27.803 回答