未知主机Maven2:在Docker中构建Maven时名称或服务未知

问题描述

我正在尝试在docker内部启动mvn clean install,但不断出现错误:

`Downloading from foo: http://maven2:8081/repository/foo/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.239 s
[INFO] Finished at: 2020-10-06T13:27:37Z
[INFO] ------------------------------------------------------------------------
[ERROR] 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: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to foo (http://maven2:8081/repository/foo/): Transfer failed for http://maven2:8081/repository/foo/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom: Unknown host maven2: Name or service not known -> [Help 1]`

我正在使用公司本地专家。设置文件为:

<?xml version="1.0" encoding="UTF-8"?>
<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 
http://maven.apache.org/xsd/settings-1.0.0.xsd">
  
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>foo</id>
      <mirrorOf>*</mirrorOf>
      <url>http://maven2:8081/repository/foo/</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>foo</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>foo</activeProfile>
  </activeProfiles>
</settings>

如果我删除settings.xml或安装程序重定向到中央

<mirror>
    <id>https-mirror</id>
    <name>Https Mirror Repository</name>
    <url>https://repo1.maven.org/maven2</url>
    <mirrorOf>central</mirrorOf>
</mirror>

该程序的构建没有问题,但是生成产品的脚本第二次失败,它需要下载存储在我们关系中的内容。

maven2的所有请求似乎都是有效的。如果我使用browserwget来访问http://maven2:8081/repository/foo/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom,我会毫无问题地得到它。

Maven版本:

root@49c24e7d4554:/mnt# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/apache-maven
Java version: 1.8.0_265,vendor: Oracle Corporation,runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US,platform encoding: UTF-8
OS name: "linux",version: "4.19.128-microsoft-standard",arch: "amd64",family: "unix"

其他人也使用相同的docker映像和设置文件,似乎对他们有用。

我还尝试从/.m2/中删除/ repository 重新启动图像 几天之内,就好像> 50种不同的解决方案在堆栈上溢出了一样,似乎什么也没起作用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...