首页 > 解决方案 > 创建maven项目时如何修复“找不到前缀'原型'的插件”错误

问题描述

我尝试使用以下命令创建一个 Maven 项目:

mvn archetype:generate

不幸的是,它不起作用,所以我在网上搜索。感谢stackoverflow,我了解到该错误与我公司的代理有关,因此我在以下位置创建了一个settings.xml文件:

${user.home}/.m2/settings.xml

这是 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">

  <proxies>
    <proxy>
      <id>my_id</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>my_host</host>
      <port>my_port</port>
      <nonProxyHosts>localhost|127.0.0.1|*.my_company.com</nonProxyHosts>
    </proxy> 
  </proxies>
</settings>

代理标签是同事给的,应该是正确的。
但是,我仍然有一个错误,这是错误消息:

[INFO] Scanning for projects...
Downloading from central: 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 from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
***
Some warnings here
***
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Access denied to: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Access denied to: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.285 s
[INFO] Finished at: 2019-04-09T16:05:17+02:00
[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 (C:\Users\ho.hince\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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

C:\Users\ho.hince\Desktop\Spring\test>mvn archetype: generate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.132 s
[INFO] Finished at: 2019-04-09T16:09:58+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\ho.hince\Desktop\Spring\test). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/MissingProjectException

我想知道主机或端口号是否错误,所以我尝试多次更改它以查看会发生什么。
当我将端口号更改为随机端口时,我仍然有同样的错误,但过程会大大减慢。

我已经在这个网站和其他网站上搜索了几个小时的解决方案,但仍然找不到解决方案。
非常抱歉,如果我在这个问题上犯了错误,但我已经花了半个小时才完成并确保按照说明进行操作。

先感谢您。:)

标签: xmleclipsemavenproxysettings

解决方案


我找到了解决方案,我更改了 settings.xml 服务器标记。
我将其更改为 Nexus 网址,以便下载我公司的罐子。

如果您对 SSL 证书有同样的问题,我需要在 JAVA 中导入证书。

sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

您可以在此视频中找到答案:
https ://www.youtube.com/watch?v=z3tAp3m5YBo


推荐阅读