禁用Maven中央存储库 [英] Disable Maven central repository

查看:556
本文介绍了禁用Maven中央存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司的政策皱眉的工件下载自动(他们必须批准),所以为了使用Maven我需要禁用访问Maven的中央存储库。

My company's policy frowns upon artifacts downloaded automatically (they have to be approved), so in order to use Maven I need to disable access to Maven's central repository.

换句话说,我不想让Maven尝试从中央进行任何下载。

In other words, I don't want Maven to attempt any downloads from central.

我知道如何配置本地存储库(网络化或非网络化),我的想法是使用一个有福的机器更新本地存储库。

I know how to configure a local repository (networked or not), my idea is using a "blessed" machine to update the local repository.

我可以在代理/网络级别阻止请求,但我要问如何使用Maven的配置。

PS: I could block requests at the proxy/network level, but I'm asking about how to do it with Maven's configuration.

UPDATE
我终于找到了怎么做。在maven的家中, conf 目录是一个全局 settings.xml
你可以设置一个镜像到 central ,指向一些内部服务器或者只是覆盖它的定义。

UPDATE I finally figured out how to do it. In maven's home, in the conf directory is a global settings.xml. You can either set a mirror to central that points to some internal server or just override it's definition.

推荐答案

同意。

您的问题的具体答案是我的回答的第二部分:-)

The specific answer to your question is the second part of my answer :-)

我建议设置一个本地Maven存储库管理器。好的选项如下:

I'd recommend setting up a local Maven repository manager. Good options are the following:

  • Nexus
  • Artifactory
  • Archiva

所有这些都可以充当

您也可能对Nexus的专业版感兴趣。其中包括用于管理外部库的采购套件。它还提供用于集中管理Maven设置文件的Maven插件,这是我的回答的第二部分...

You might also be interested in the Profession version of Nexus. It includes a Procurement suite for managing external libraries. It also provides Maven plugins for centrally managing the Maven settings file, which is the second part of my answer...

更新位于以下目录中的设置文件

Update the settings file located in the following directory:

$ HOME / .m2 / settings.xml

$HOME/.m2/settings.xml

指定所有中央请求都应重定向到本地Maven存储库:

Specify that all central requests should be redirected to the local Maven repository:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <mirrors>
    <mirror>
      <id>central-proxy</id>
      <name>Local proxy of central repo</name>
      <url>http://<hostname>/central</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

这篇关于禁用Maven中央存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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