gpt4 book ai didi

maven-2 - Nexus/Artifactory 可以存储互联网 Maven Artifactory 的副本吗?

转载 作者:行者123 更新时间:2023-12-04 23:33:49 27 4
gpt4 key购买 nike

当从 Internet 上的公共(public)存储库(如 Maven Central)下载 Artifactory 时,我想让 Nexus(或 Artifactory,我们尚未决定)存储 Artifactory 的副本。

基本上,如果您的本地存储库中没有 jar 并且存储库管理器也没有它,我想向存储库管理器询问 jar,让它发送给我,并将其存储在存储库中经理和我本地的 repo 。然后,当另一个人向 repo manager 询问同一个 jar 时,它会从 repo manager 将其发送给他们,然后他们将其保存在本地 repo 中,而无需访问 Maven Central。

这听起来像是开箱即用的工作方式,但我看不到。我可以通过 repo 管理器查看 Maven 中心上的 Artifactory ,但是当我使用 Netbeans 向我的项目添加依赖项时,它会直接从 Maven 中心下载它(显然)。 repo 管理器中没有缓存任何内容(据我所知)。

最佳答案

Nexus 具有代理存储库的概念,它几乎完全符合您的描述。见Proxying Public Repositories书的部分了解详细信息。

Artifactory 有一个类似的功能,称为 Virtual repositories .

Proxying and caching a remote public repository can speed up your builds by reducing redundant downloads over the public internet. If a developer in your organization needs to download version 2.5 of the Spring Framework and you are using Nexus, the dependencies (and the dependency's dependencies) only need to be downloaded from the remote repository once. With a high-speed connection to the Internet this might seem like a minor concern, but if you are constantly asking your developers to download hundreds of megabytes of third-party dependencies, the real cost savings are going to be the time it takes Maven to check for new versions of dependencies and to download dependencies over the public internet.



您可以通过将存储库管理器设置为中央的镜像来阻止您的 Maven 安装尝试连接到中央,然后将对中央的请求定向到您的存储库管理器。例如,将以下内容添加到 <mirrors> Maven 的 settings.xml 部分将请求重定向到您的存储库管理器的中心:
<mirror>
<id>central-proxy</id>
<mirrorOf>central</mirrorOf>
<url>http://myrepo/nexus/content/groups/public</url>
</mirror>

我倾向于设置 repository group包含几个远程存储库。就我的 Maven 安装而言,该组充当单个存储库,但会整理来自多个远程存储库的 Artifactory 。

关于maven-2 - Nexus/Artifactory 可以存储互联网 Maven Artifactory 的副本吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1478157/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com