【问题标题】:mvn command returns: [ERROR] The goal you specified requires a project to execute but there is no POM in this directorymvn 命令返回:[错误] 你指定的目标需要一个项目来执行,但是这个目录下没有 POM
【发布时间】:2020-02-14 23:30:37
【问题描述】:

使用archetype:generate 以与Maven in 5 Minutes 中所述相同的方式创建项目。
收到此错误:

[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/mnt/c/Users/etomort/quartz-poc). Please verify you invoked Maven from the correct directory. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (/mnt/c/Users/etomort/quartz-poc). Please verify you invoked Maven from the correct directory.

既然是这么基本的东西,我就糊涂了……

我检查了这两个问题:

但接受的答案都没有解决问题。
所以,我正在创建这个问题,以防有人一开始就没有得到它。

顺便说一下,输入的Maven命令是:

mvn archetype:generate -DgroupId=com.mycompany -DartifactId=quartz-poc -DarchetypeArtifactId= maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false  

【问题讨论】:

    标签: bash maven maven-archetype


    【解决方案1】:

    如果您在 Windows 上并使用cmd 命令行或PowerShell,则需要将参数括在引号中:

    mvn archetype:generate "-DgroupId=com.mycompany" "-DartifactId=quartz-poc" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.4" "-DinteractiveMode=false"
    

    在某些机器上,它可以在没有 cmd 引号的情况下工作。

    【讨论】:

    • 我在 Windows 上,但使用的是 WSL,但失败了,因为我在没有注意到的情况下引入了空格。
    • 我一直忘记这一点。这应该是正确的答案。
    • 在 WSL 中,引号并不是真正需要的。
    【解决方案2】:

    注意mvn 命令中的空格

    = 前后的任何空格都会使mvn 失败:

    在我的问题中,额外的空间位于archetypeArtifactId
    尽管无论它在哪里,Maven 都会抱怨同样的信息。

    我无意中引入了具有bash 自动完成功能的空格:

    【讨论】:

      【解决方案3】:

      如果您在 Windows 上并使用 cmd 命令行:

      mvn archetype:generate -DgroupId=com.mycompany -DartifactId=quartz-poc -DarchetypeArtifactId= maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

      如果您在 Windows 上并使用 PowerShell 命令行:

      mvn archetype:generate "-DgroupId=com.mycompany" "-DartifactId=quartz-poc" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.4" "-DinteractiveMode=false"

      【讨论】:

        猜你喜欢
        • 2013-04-27
        • 2022-07-19
        • 1970-01-01
        • 1970-01-01
        • 2022-01-02
        • 1970-01-01
        • 2012-12-02
        • 2014-03-20
        • 2013-10-18
        相关资源
        最近更新 更多