封闭网络中的私有Maven存储库

时间:2018-03-14 19:27:14

标签: maven maven-plugin nexus

我在一个封闭的网络中,无法访问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>

1 个答案:

答案 0 :(得分:2)

在settings.xml中将您的存储库添加为all的镜像,这样它就不会查看任何其他存储库。

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

相关问题