【问题标题】:mvn:generate results in "The goal you specified requires a project to execute but there is no POM in this directory"mvn:generate 导致“您指定的目标需要执行项目,但此目录中没有 POM”
【发布时间】:2022-01-02 03:02:23
【问题描述】:

我正在关注他们网站上的 Maven 教程:https://maven.apache.org/guides/getting-started/index.html#how-do-i-make-my-first-maven-project

当我运行以下 Maven 生成命令时,我收到一个关于缺少 POM.xml 文件的错误。

mvn -B archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4

错误是:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.074 s
[INFO] Finished at: 2021-11-23T15:52:42Z
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\Jay\Desktop\java-youtube). Please verify you invoked Maven from the correct directory. -> [Help 1]

我遇到的困惑是根据教程,运行此命令后应该生成POM.xml,但我得到了上面的错误。

知道我做错了什么吗?

mvn --version 结果:

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\Jay\bin\apache-maven-3.8.4
Java version: 17, vendor: Oracle Corporation, runtime: C:\Users\Jay\.jabba\jdk\openjdk@1.17.0
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

【问题讨论】:

    标签: java powershell maven


    【解决方案1】:

    如果我用 PowerShell 运行你的脚本,我会得到同样的错误。

    您可以更改您的 shell 或使用适用于 PowerShell 的版本:

    mvn -B archetype:generate -D"groupId=com.mycompany.app" -D"artifactId=my-app" -D"archetypeArtifactId=maven-archetype-quickstart" -D"archetypeVersion=1.4"
    

    这可能与以下内容重复:Cannot run Maven using mvn -D argument within Microsoft Powershell, but works in Command Prompt

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-19
      • 2013-04-27
      • 1970-01-01
      • 1970-01-01
      • 2015-09-03
      • 2013-06-14
      • 2017-05-06
      相关资源
      最近更新 更多