如何禁用 maven 阻止外部 HTTP 存储库? [英] How to disable maven blocking external HTTP repositores?
问题描述
Maven 自 3.8.1 版起默认阻止外部 HTTP 存储库(参见 https://maven.apache.org/docs/3.8.1/release-notes.html)
有没有办法禁用它或从这个规则中豁免仓库?
通过检查负责默认 HTTP 阻塞的 Maven git 存储库中的提交,我找到了一个解决方案:https://github.com/apache/maven/commit/907d53ad3264718f66ff15e15e15e1363d76b07dd0c05f" 我的解决方法如下: 在 Maven 设置中(位于 如果您在一个项目中工作并且无法确保 Maven 设置始终如此,例如因为你与其他人共享代码或者想使用 CI/CD 进行自动化测试,你可以执行以下操作: 在项目中添加一个名为 在 示例: 如果您在 然后你需要在 我希望我的工作可以帮助其他偶然发现此问题的人.但是,如果您有更优雅或更好的解决方案,请分享! Maven blocks external HTTP repositories by default since version 3.8.1 (see https://maven.apache.org/docs/3.8.1/release-notes.html) Is there a way to disable that or to exempt a repository from this rule? I found a solution to do this by inspecting the commit in the Maven git repository that is responsible for the default HTTP blocking: https://github.com/apache/maven/commit/907d53ad3264718f66ff15e1363d76b07dd0c05f My solution is as follows: In the Maven settings (located in If you work in a project and cannot make sure the Maven settings are always like that, e.g. because you share code with other people or want to use CI/CD with automated testing, you may do the following: Add a directory named Where inside the Example: If you have the following HTTP repositories defined in the Then you need in the I hope my work can help other people who stumble upon this. However, if you have a more elegant or better solution, please share! 这篇关于如何禁用 maven 阻止外部 HTTP 存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!${maven.home}/conf/settings.xml
或 ${user.home}/.m2/settings.xml
),必须删除以下条目:<镜像><id>maven-default-http-blocker</id><mirrorOf>外部:http:*</mirrorOf>
.mvn
的目录.在.mvn
目录下,添加一个名为maven.config
的文件,内容为--settings ./.mvn/local-settings.xml
.在.mvn
目录下,添加一个名为local-settings.xml
的文件.该文件应如下所示:<mirrorOf>
标签中,你需要指定哪个仓库被阻止,在<url>
标签中,你指定的原始url再次存储库.您需要为您拥有的每个被阻止的存储库创建此解除阻止程序镜像.pom.xml
中定义了以下 HTTP 存储库:.mvn/local-settings.xml
:<镜子><镜子><id>release-http-unblocker</id><mirrorOf>central</mirrorOf><姓名></姓名><url>http://my-url/libs-release</url><blocked>false</blocked></镜像><镜子><id>snapshot-http-unblocker</id><mirrorOf>快照</mirrorOf><姓名></姓名><url>http://my-url/libs-snapshot</url><blocked>false</blocked></镜像></镜子>
${maven.home}/conf/settings.xml
or ${user.home}/.m2/settings.xml
), the following entry must be removed:<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
.mvn
in the project. In the .mvn
directory, add a file named maven.config
with the content --settings ./.mvn/local-settings.xml
. In the .mvn
directory, add a file named local-settings.xml
. This file should look like this:<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
<mirrors>
<mirror>
<id>my-repository-http-unblocker</id>
<mirrorOf>my-blocked-http-repository</mirrorOf>
<name></name>
<url>http://........</url>
<blocked>false</blocked>
</mirror>
</mirrors>
</settings>
<mirrorOf>
tag, you need to specify what repository is blocked, and in the <url>
tag, you specify the original url of the repository again. You need to create this unblocker mirror for every repository you have that is blocked.pom.xml
:<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://my-url/libs-release</url>
</repository>
<repository>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://my-url/libs-snapshot</url>
</repository>
</repositories>
.mvn/local-settings.xml
:<mirrors>
<mirror>
<id>release-http-unblocker</id>
<mirrorOf>central</mirrorOf>
<name></name>
<url>http://my-url/libs-release</url>
<blocked>false</blocked>
</mirror>
<mirror>
<id>snapshot-http-unblocker</id>
<mirrorOf>snapshots</mirrorOf>
<name></name>
<url>http://my-url/libs-snapshot</url>
<blocked>false</blocked>
</mirror>
</mirrors>