Maven无法检索org.apache.maven.plugins的插件描述符:maven-clean-plugin:2.5

时间:2016-03-10 15:29:23

标签: maven

由于我对Maven不熟悉,我尝试创建一个类似于Maven in 5 Minutes的小空项目。虽然我每次都跑

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

我收到此错误:

[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.546 s
[INFO] Finished at: 2016-03-10T14:33:31+01:00
[INFO] Final Memory: 6M/109M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'archetype' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/rpod/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix 'archetype' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/rpod/.m2/repository), central (https://repo.maven.apache.org/maven2)]
    at org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver.resolve(DefaultPluginPrefixResolver.java:93)
    at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.findPluginForPrefix(MojoDescriptorCreator.java:266)
    at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:220)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:103)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:83)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:89)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

我查了几页虽然他们要么说我的防火墙阻止了它,我检查了它但是它当前处于非活动状态,或者我的代理设置错误,这也不是因为我没有使用它。

我还尝试手动打开这些链接,它们工作得很好,我也尝试在不同的机器上运行它,它开箱即用。

我的Maven版本(通过mvn --version命令):

Java version: 1.8.0_66-internal, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.2.0-30-generic", arch: "amd64", family: "unix"

最后我当前的settings.xml设置:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                           https://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository>${user.home}/.m2/repository</localRepository>
        <interactiveMode>true</interactiveMode>
        <usePluginRegistry>false</usePluginRegistry>
        <offline>false</offline>
</settings>

即使查看了使用-X参数执行它的整个日志,我仍然没有看到问题。

我错过了什么吗?在此先感谢您的帮助。

3 个答案:

答案 0 :(得分:1)

尝试精确指定插件+版本:

mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

另外,请尝试检查您共享的settings.xml是否正在使用。该文件可以存在于:

  • Maven安装:$M2_HOME/conf/settings.xml
  • 用户的安装:${user.home}/.m2/settings.xml

用户的安装将覆盖全局安装。

答案 1 :(得分:1)

事实证明我的JDK版本因某些原因而被破坏了。在完全清除每个目录并重新安装JDK和Maven后,它再次运行。

答案 2 :(得分:0)

将JAVA_HOME和PATH切换到jdk1.7.0_80后,我遇到了同样的问题。

将其切换回jdk1.8.0_172为我解决了该问题。