封闭网络中的私有Maven存储库 [英] Private Maven Repository in Closed Network

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

问题描述

我处于封闭网络中,无法访问 http://repo.maven.apache.org 我们设置了一个Nexus服务器,然后将所有.m2下载到可公开访问的计算机上,刻录到磁盘上,然后上传到我们的Nexus服务器上(效率低下,但有必要)

I am in a closed network, do not have access to http://repo.maven.apache.org We set up a Nexus server and we download all of our .m2's on a publicly accessible computer, burn to disk, then upload to our Nexus server (inefficient but necessary)

当前,我正在尝试将系统设置为仅使用我的nexus服务器,当前它尝试访问 http ://repo.maven.apache.org (假设设置为false)如果我设置为true,它甚至不会尝试进入我的私人仓库.基本上,我只需要Maven仅查看我的联系实例,甚至不尝试转到 http://repo .maven.apache.org

Currently I am trying to set up the system to only use my nexus server, currently it tries to go to http://repo.maven.apache.org (assuming is set to false) If I have set to true, it does not even attempt to go to my private repo. Basically, I just need my Maven to only look at my nexus instance, not even attempt to go to http://repo.maven.apache.org

这是我的settings.xml和pom.xml文件的一部分:

Here are portions of my settings.xml and pom.xml files:

<!-- Settings.xml in my .m2 directory -->
<offline>true</offline>
<servers>
    <server>
        <id>mynexus</id>
        <username>xxx</username>
        <password>xxx</username>
    </server>
    <server>
        <id>mynexusplugins</id>
        <username>xxx</username>
        <password>xxx</username>
    </server>
</servers>


<!-- pom.xml -->
<repositories>
    <repository>
        <id>mynexus</id>
        <url>http://192.168.100.4:8081/....</url>
    </repository>
</repository>

<pluginRepositories>
    <pluginRepository>
        <id>mynexusplugins</id>
        <url>http://192.168.100.4:8081/....</url>
    </pluginRepository>
</pluginRepository>

推荐答案

将您的存储库添加为settings.xml中所有存储库的镜像,这样就不会再有其他存储库了.

Add your repository as mirror of all in the settings.xml, this way it won't look any other repo.

 <mirrors>
    <mirror>
      <id>yourRepo</id>
      <name>yourRepo name</name>
      <url>your url</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

https://maven.apache.org/guides/mini /guide-mirror-settings.html

作为旁注,如果您在maven中设置离线(通过命令行或配置),它将仅使用本地m2文件夹.

As a side note, If you set offline in maven(via command line or config) it will only use local m2 folder.

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

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