Nexus/Artifactory可以存储Internet Maven工件的副本吗? [英] Can Nexus/Artifactory store a copy of an internet Maven artifact?

查看:101
本文介绍了Nexus/Artifactory可以存储Internet Maven工件的副本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让Nexus(或Artifactory,我们尚未决定)在从Internet上的公共存储库(例如Maven Central)下载人工制品时存储该人工制品的副本.

I would like to have Nexus (or Artifactory, we're not decided yet) store a copy of an artifact when it is downloaded from a public repository on the internet (like Maven Central).

基本上,如果您的本地存储库中没有该jar,并且存储库管理器也没有,我想向存储库的仓库询问它,将其发送给我,然后将其存储在仓库管理器和我的本地仓库中.然后,当另一个人向存储库管理员请求相同的jar时,它会从存储库管理器中将其发送给他们,他们将其保存在本地存储库中,而无需访问Maven中心.

Basically, if you don't have the jar in your local repo and the repo manager doesn't have it either, I want to ask the repo manager for the jar, have it send it to me, and store it both in the repo manager and in my local repo. Then, when another person asks the repo manager for the same jar, it sends it to them from the repo manager and they save it in their local repo, without needing to hit Maven central.

这听起来像是开箱即用,但我看不到.我可以通过回购管理器看到Maven Central上的工件,但是当我使用Netbeans向项目添加依赖项时,它将直接从Maven Central下载(显然).据我所知,回购管理器中什么也没有缓存.

This sounds like how it should work out of the box, but I don't see it. I can see the artifacts on Maven central through the repo manager, but when I use Netbeans to add a dependency to my project, it downloads it straight from Maven central (apparently). Nothing gets cached in the repo manager (as far as I can see).

推荐答案

Nexus具有代理存储库的概念,它几乎可以完全满足您的描述.请参阅本书的代理公共存储库部分以了解以下内容:详细信息.

Nexus has the concept of proxy repository which does almost exactly what you describe. See the Proxying Public Repositories section of the book for details.

Artifactory具有类似的功能,称为虚拟存储库.

Artifactory has a similar feature called Virtual repositories.

代理和缓存远程公共存储库可以通过减少公共Internet上的冗余下载来加快构建速度.如果您组织中的开发人员需要下载Spring Framework 2.5版,并且您正在使用Nexus,则只需从远程存储库中下载一次依赖关系(以及依赖关系的依赖关系).通过高速连接到Internet,这似乎是一个小问题,但是如果您不断要求开发人员下载数百MB的第三方依赖项,则真正的成本节省将是Maven花费的时间.检查新版本的依赖项,并通过公共Internet下载依赖项.

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.

通过将存储库管理器设置为Central的镜像,可以停止尝试连接到Central的Maven安装,然后将对Central的请求定向到您的存储库管理器.例如,将以下内容添加到Maven的settings.xml的<mirrors>部分中,以将请求重定向到中心到您的存储库管理器:

You can stop your Maven install from ever trying to connect to Central by setting up your repository manager as a mirror of central, requests to central will then be directed to your repository manager. For example add the following to the <mirrors> section of Maven's settings.xml to redirect requests to central to your repository manager:

<mirror>
  <id>central-proxy</id>
  <mirrorOf>central</mirrorOf>
  <url>http://myrepo/nexus/content/groups/public</url>
</mirror>

我倾向于设置存储库组,其中包含多个远程存储库.就我的Maven安装而言,该组充当单个存储库,但会整理来自多个远程存储库的工件.

I tend to set up a repository group containing several remote repositories. The group acts as a single repository as far as my Maven install is concerned, but collates artifacts from several remote repositories.

这篇关于Nexus/Artifactory可以存储Internet Maven工件的副本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆