【问题标题】:Private Maven Repository in Closed Network封闭网络中的私有 Maven 存储库
【发布时间】:2018-03-14 19:27:13
【问题描述】:

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

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

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

<!-- 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>

【问题讨论】:

    标签: maven maven-plugin nexus


    【解决方案1】:

    将您的存储库添加为 settings.xml 中所有内容的镜像,这样它就不会看起来像任何其他存储库。

     <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 文件夹。

    【讨论】:

      猜你喜欢
      • 2011-01-27
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      • 1970-01-01
      • 2016-04-22
      • 1970-01-01
      • 2021-12-07
      • 2022-09-13
      相关资源
      最近更新 更多