如何解决未知主机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>
<mirror>
<id>https-mirror</id>
<name>Https Mirror Repository</name>
<url>https://repo1.maven.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
该程序的构建没有问题,但是生成产品的脚本第二次失败,它需要下载存储在我们关系中的内容。
对maven2
的所有请求似乎都是有效的。如果我使用browser
或wget
来访问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 举报,一经查实,本站将立刻删除。