我面临着一个与Maven存储库解析有关的奇怪现象(Maven版本: 3.8.4),我无法解释这些现象。具体情况如下:
我们有一个用于中央存储库的内部Nexus代理设置。网址为http://[companyDomain]:8081/repository/maven-central
我在pom.xml中声明一个存储库如下:
<repository>
<id>nexus-maven-central</id>
<name>Maven Central Repository Internal Proxy</name>
<url>http://[companyDomain]:8081/repository/maven-central</url>
<layout>default</layout>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>有效的pom将上面的存储库显示为存储库列表中的第一个存储库,默认的Maven Central存储库(id:central)将在此之后显示出来。
但是,当我构建pom时,Maven将直接转到Maven Central存储库,而不是考虑上面的存储库。
现在,当我在本地主机中启动一个Nexus实例并将上面的URL更改为:
http://localhost:8081/repository/maven-centralMaven解析存储库并从本地主机下载。
此外,当我再次在pom中使用http://[companyDomain]:8081/repository/maven-central,并在全局setting.xml中配置镜像时(我没有使用特定于用户的设置)
<mirror>
<id>nexus-maven-central-mirror</id>
<name>Mirror for Maven Central Repository</name>
<url>http://[companyDomain]:8081/repository/maven-central</url>
<mirrorOf>central</mirrorOf>
</mirror>Maven完美地解析了内部代理存储库并下载了工件。
至于环境方面,我正在通过VPN连接到公司网络。当我连接到VPN时,内部Nexus服务器的IP是可解析的;当我尝试上述操作时,不会出现VPN中断。
我希望Maven在配置“从.下载”时至少尝试内部代理回购。消息,这种性质的任何内容都不会出现在控制台中。它直接进入中央仓库。
我还使用以下URL进行了测试:
虽然我知道Maven不喜欢从' http‘下载,Maven Central明确声明如果通过http访问它将发送错误,那么问题是为什么它从http上的本地主机下载而不是远程;Maven是否有忽略远程http的行为。
或者Maven对“localhost”和远程repos的处理方式不同。或者还有什么其他的事我错过了。
不幸的是,我无法找到关于上述问题的大量文件,如果能提供任何帮助,我将不胜感激。
发布于 2022-02-10 20:14:59
第一件事是:I am declaring a repository in the pom.xml as follows:,如果使用存储库管理器,总是通过settings.xml定义存储库,如下所示:
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>https://central</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://central</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>从pom文件中删除所有存储库条目..。
https://stackoverflow.com/questions/71061665
复制相似问题