为什么会出现错误“在当前项目中找不到前缀'帮助'的插件”当我在命令提示符下写mvn help:effective-pom时? [英] why is there the error "No plugin found for prefix 'help' in the current project" when I write mvn help:effective-pom in the command prompt?

查看:264
本文介绍了为什么会出现错误“在当前项目中找不到前缀'帮助'的插件”当我在命令提示符下写mvn help:effective-pom时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读关于maven的教程,应该提到我对此一无所知。我已经成功完成了第一章和第二章,这是关于它的设置。但在第3章Maven Pom中我遇到了问题。在上一段中,它表示要在您希望的任何目录中创建一个pom.xml文件并将其写入其中:

I'm reading a tutorial about maven and it should be mentioned that I know nothing about it. I have done first and second chapter successfully which was about it's setup. but in chapter 3 which is "Maven Pom" I have a problem. In last paragraph it says to make a "pom.xml" file in any directory you wish and write this in it:

 <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>

然后它说一个简单的方法来查看超级POM的默认配置是通过运行以下命令:命令提示符中的 mvn help:effective-pom

and then it says that an easy way to look at the default configurations of the super POM is by running the following command: mvn help:effective-pom in the command prompt.

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

But when I try this, I get this error:

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

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

This is the tutorial I mentioned above: maven tutorial

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

Why there is no plugin help in my repository folder?! and how I can get it?

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

This is the output of mvn --version in the cmd:

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帮助的结果:effective-pom(前十行)

This is the rezult of mvn -X help:effective-pom(first ten lines)

[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 是该插件应该执行的目标。

When you execute mvn help:effecitve-pom, help is a prefix which represents a specific plugin while effective-pom is the goal from that plugin that should be executed.

第一件事Maven会尝试根据给定的前缀查找完整的插件(因此在您的情况下,前缀 help )。通常,它通过检查本地存储库中的 /org/apache/maven/plugins/maven-metadata.xml 文件来执行此操作(默认情况下,您的本地存储库存储在<$下) c $ c>%HOME%/。m2 / repository )。

The first thing Maven does is try to lookup the full plugin based on the given prefix (so in your case the prefix help). Normally it does this by checking the /org/apache/maven/plugins/maven-metadata.xml file in your local repository (by default your local repository is stored under %HOME%/.m2/repository).

如果此文件不存在则会尝试远程检查(再次默认配置将使用maven central),然后将使用以下名称将此文件缓存在本地存储库中: maven-metadata-< remote-repo-id> .xml (因此对于maven中心,它将是: maven-metadata-central.xml )。如果此时它无法远程访问此文件,那么它将无法找到该插件并且将无法构建。这正是您所遇到的。

If this file doesn't exist then it tries to check it remotely (again default configuration would use maven central), and will then cache this file in your local repository with the following name: maven-metadata-<remote-repo-id>.xml (so for maven central it would be: maven-metadata-central.xml). If at this point it is unable to access this file remotely then it wont be able to find the plugin and will fail the build. This is exactly what you are experiencing.

您的问题

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

There are two main reasons why it wont be able to resolve the plugin:


  • 存储库中的本地文件在某种程度上已损坏

  • maven无法访问远程存储库(所以基本上是你的网络连接问题)。

你可以在执行maven构建时使用调试标志 -X 以接收有关正在进行的操作的更多信息。执行以下操作时:

You can use the debug flag -X when executing your maven build to receive more information about what is going on. For you executing the following:

mvn -X help:effective-pom

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

should provide information about how it is trying to resolve the plugin prefix. For example if I execute this command I see the following:

[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.

我从远程存储库获取的本地缓存文件是最新的,所以它只会使用它。

My locally cached file from the remote repository is up to date so it will just use that.

执行 /org/apache/maven/plugins/maven-metadata.xml /您的本地存储库中是否存在org / apache / maven / plugins / maven-metadata-central.xml ?如果他们没有,那么很可能你有互联网连接问题。如果他们确实存在,那么他们可能会腐败。使用 -X 标志运行的结果是什么,它提供了哪些信息?

Do either /org/apache/maven/plugins/maven-metadata.xml or /org/apache/maven/plugins/maven-metadata-central.xml exist in your local repository? If they don't then most likely you have an internet connection problem. If they do exist then they might be corrupt. What is the result of running with the -X flag, what information does it provide?

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

After all this usually the simplest solution is to delete your local repository (by default %HOME%/.m2/repository, but running maven with the -X flag will tell you exactly where it is), and execute maven again. By deleting the local repository you force maven to download everything again.

这篇关于为什么会出现错误“在当前项目中找不到前缀'帮助'的插件”当我在命令提示符下写mvn help:effective-pom时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆