创建Maven项目时如何修复'找不到用于前缀'原型'的插件错误

时间:2019-04-09 14:38:35

标签: xml eclipse maven proxy settings

我尝试使用以下命令创建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

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

我已经在该网站和其他网站上搜索了数小时的解决方案,但仍然找不到解决的办法。
对不起,如果我在这个问题上犯了一个错误,但我花了半个小时一个小时,并确保按照说明进行操作。

先感谢您。 :)
附注:对不起,由于英文错误,这不是我的主要语言。

1 个答案:

答案 0 :(得分:0)

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

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

  

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

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