首页 > 解决方案 > Maven 错误未知主机 repo.maven.apache.org

问题描述

我正在尝试docker-compose build在 CentOS Linux 版本 8.2.2004 上构建一个 docker 容器。当我执行命令时,我收到以下错误消息

[ERROR] Plugin org.apache.maven.plugins:maven-javadoc-plugin:3.1.1 or one of its dependencies could not be resolved: 
Failed to read artifact descriptor for org.apache.maven.plugins:maven-javadoc-plugin:jar:3.1.1: 
Could not transfer artifact org.apache.maven.plugins:maven-javadoc-plugin:pom:3.1.1 from/to central (https://repo.maven.apache.org/maven2): 
Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-javadoc-plugin/3.1.1/maven-javadoc-plugin-3.1.1.pom: 
Unknown host repo.maven.apache.org: Temporary failure in name resolution -> [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/PluginResolutionException
ERROR: Service 'web' failed to build: The command '/bin/sh -c mvn clean package -am -DskipTests -Dmaven.javadoc.skip=true -P deployment' returned a non-zero code: 1

当我在本地机器上构建 docker 容器时,它工作得很好。因此容器或其中的任何配置都没有问题。我做了一些研究,表明 CentOS 服务器上可能存在代理问题,但echo "$HTTP_PROXY"返回echo "$HTTPS_PROXY"一个空行 - 因此我想没有使用代理。

此外,当我执行时,curl https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-javadoc-plugin/3.1.1/maven-javadoc-plugin-3.1.1.pom我会得到一个外观正确的 xml 文件。

当我执行时,curl https://repo.maven.apache.org/maven2我得到

<html>
<head><title>302 Moved Temporarily</title></head>
<body>
<h1>302 Moved Temporarily</h1>
<ul>
<li>Code: Found</li>
<li>Message: Resource Found</li>
<li>RequestId: 235378792B04A00C</li>
<li>HostId: b2HKaI47VR5MaiW8bmG9FUGxgZ7u97XeT5Bfm/rs54wVSNjH0hNQsZ2/d4sGaACGboThVlIo5iM=</li>
</ul>
<hr/>
</body>
</html>

curl -L https://repo.maven.apache.org/maven2向我展示了一个长的 html 文档(如预期的那样)。

任何帮助将不胜感激

标签: dockermavencentos

解决方案


推荐阅读