gpt4 book ai didi

java - 为什么我写mvn help :effective-pom in the command prompt?时出现错误 "No plugin found for prefix ' help' in the current project"

转载 作者:搜寻专家 更新时间:2023-11-01 01:42:43 31 4
gpt4 key购买 nike

我正在阅读有关 Maven 的教程,应该提到我对此一无所知。我已经成功地完成了第一章和第二章,这是关于它的设置的。但是在第 3 章“Maven Pom”中我遇到了问题。在最后一段中,它说在你想要的任何目录中创建一个“pom.xml”文件并在其中写入:

 <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.companyname.project-group</groupId>
<artifactId>project</artifactId>
<version>1.0</version>

</project>

然后它说查看 super POM 默认配置的一种简单方法是在命令提示符下运行以下命令:mvn help:effective-pom

但是当我尝试这个时,我得到了这个错误:

No plugin found for prefix 'help' in the current project

这是我上面提到的教程:maven tutorial

为什么我的存储库文件夹中没有插件帮助?!我怎样才能得到它?

这是 cmd 中 mvn --version 的输出:

Apache Maven 3.2.3
Maven home: C:\apache-maven-3.2.3
Java version: 1.6.0_13
Java home: C:\Program Files\Java\jdk1.6.0_13
Default locale: en_US, platform encoding: Cp1252
OS name: "windows Vista",version:"6.8"

这是 mvn -X help:effective-pom 的结果(前十行)

[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.4
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-resources-plugin:2.6: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-surefire-plugin:2.12.4: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-compiler-plugin:3.1: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-jar-plugin:2.4: Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:2.4
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom

最佳答案

背景信息

当你执行 mvn help:effecitve-pom , help effective-pom 是代表特定插件的前缀是应该执行的那个插件的目标。

Maven 做的第一件事是尝试根据给定的前缀查找完整的插件(所以在你的例子中是前缀 help )。通常它通过检查 /org/apache/maven/plugins/maven-metadata.xml 来做到这一点本地存储库中的文件(默认情况下,您的本地存储库存储在 %HOME%/.m2/repository 下)。

如果此文件不存在,则它会尝试远程检查它(同样默认配置将使用 maven central),然后将此文件缓存在您的本地存储库中,名称如下:maven-metadata-<remote-repo-id>.xml (因此对于 Maven Central 来说,它将是:maven-metadata-central.xml)。如果此时它无法远程访问此文件,那么它将无法找到该插件并将导致构建失败。这正是您正在经历的。

您的问题

无法解析插件的主要原因有两个:

  • 您存储库中的本地文件以某种方式损坏
  • maven 无法访问远程存储库(所以基本上是您的互联网连接有问题)。

您可以使用调试标志 -X在执行 Maven 构建时接收有关正在发生的事情的更多信息。为您执行以下操作:

mvn -X help:effective-pom

应该提供有关它如何尝试解析插件前缀的信息。例如,如果我执行此命令,我会看到以下内容:

[DEBUG] Resolving plugin prefix help from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Could not find metadata org.apache.maven.plugins/maven-metadata.xml in local (/home/user/.m2/repository)
[DEBUG] Skipped remote update check for org.apache.maven.plugins/maven-metadata.xml, locally cached metadata up-to-date.

我在远程存储库中的本地缓存文件是最新的,因此它将只使用它。

/org/apache/maven/plugins/maven-metadata.xml/org/apache/maven/plugins/maven-metadata-central.xml存在于您的本地存储库中吗?如果他们不这样做,那么您很可能遇到了互联网连接问题。如果它们确实存在,那么它们可能是腐败的。使用 -X 运行的结果是什么? flag,它提供什么信息?

毕竟这通常是最简单的解决方案是删除您的本地存储库(默认为 %HOME%/.m2/repository ,但使用 -X 标志运行 maven 会告诉您它的确切位置),然后再次执行 maven。通过删除本地存储库,您可以强制 Maven 重新下载所有内容。

关于java - 为什么我写mvn help :effective-pom in the command prompt?时出现错误 "No plugin found for prefix ' help' in the current project",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26364608/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com