【问题标题】:Why does not archetype:generate with parameters work for me?为什么 archetype:generate with parameters 对我不起作用?
【发布时间】:2013-06-27 11:25:14
【问题描述】:

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

【问题讨论】:

  • 这是powershell的问题。请改用 cmd。

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


【解决方案1】:

某些参数上缺少= 符号,请尝试:

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

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

【讨论】:

  • 哎呀...让我试一试
  • 我遇到了同样的问题。我认为斜线是造成它的原因。对我有用的是:mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.6.0
【解决方案2】:

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

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

【讨论】:

    【解决方案3】:

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

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

    感谢发帖者here 指出这一点。

    【讨论】:

    • 这值得拥有专门针对 Windows 的问答。这是我 4 年来第三次回到这个答案,然后说“哦,废话是的,那件事”
    • 我快疯了
    • 这是救命稻草。我忘记了在 Windows 上需要考虑这一点。非常感谢!
    【解决方案4】:

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

    【讨论】:

      【解决方案5】:

      当您在 CMD 中编写时,请尝试在 ':' 冒号之前或之后不加空格

      这样写 - mvn archetype:generate

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-10-08
        • 2016-02-27
        • 2019-01-13
        • 2015-09-07
        • 1970-01-01
        • 2023-04-03
        • 2021-09-26
        • 2022-01-11
        相关资源
        最近更新 更多