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

标签 maven-2 netbeans repository nexus artifactory

当从 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/

相关文章:

java - 单元测试在 Maven 中失败,但在 Intellij Idea 中失败

java - mysql后台定期增加某列的值

java - 是否有一个基于 hibernate 构建的简单、可扩展的 CRUD 存储库?

apache - Mercurial 推送,中止 : authorization failed

java - 如何告诉 Maven 使用最新版本的依赖项?

eclipse - 将使用 Maven 生成的项目导入 Eclipse Indigo 时出现问题

java - 为什么构建失败并显示 JRadioButton[] 数组中的空值

java - 如何从 Netbeans 中的 Java 应用程序项目中排除源文件?

sql - 错误生成 Hibernate Jpa 存储库查询

maven-2 - GroovyDoc 作为 Maven 插件