maven私服 nexus 的安裝與使用

簡介

  1. 私服不是Maven的核心概念,它僅僅是一種衍生出來的特殊的Maven倉庫。經過創建本身的私服,就能夠下降中央倉庫負荷、節省外網帶寬、加速Maven構建、本身部署構建等,從而高效地使用Maven。Nexus也是當前最流行的Maven倉庫管理軟件。

要求

  1. vps一臺
  2. 系統centos7
  3. 內存大於1g

安裝

  1. 這裏咱們使用docker進行安裝,crt鏈接到vps
  2. yum -y install docker

  3. 啓動docker: service docker start
  4. 查找nexus鏡像 : docker search nexus

  5. 通常狀況下,咱們都是用stars最高的。docker pull docker.io/sonatype/nexus
  6. 啓動nexus容器,對於之後的容器啓動,不清楚如何啓動能夠去docker hub 查看,

  7. 通常直接搜索run 就能夠找到如何啓動

  8. 訪問查看,管理員帳戶密碼 admin admin123

  9. maven設置docker

    • setting.xml設置segmentfault

      ![](https://image-static.segmentfault.com/387/191/3871913052-5d994ba5df1ee_articlex)
    • pom文件設置centos

      ![](https://image-static.segmentfault.com/168/431/1684315081-5d994ba67376c_articlex)
      
        <repositories>
              <repository>
                  <id>nexus</id>
                  <name>Team Nexus Repository</name>
                  <url>http://nexus.jetbrains.org.cn/nexus/content/groups/public</url>
                  <snapshots>
                      <enabled>true</enabled>
                      <updatePolicy>always</updatePolicy>
                  </snapshots>
              </repository>
          </repositories>
          <pluginRepositories>
              <pluginRepository>
                  <id>nexus</id>
                  <name>Team Nexus Repository</name>
                  <url>http://nexus.jetbrains.org.cn/nexus/content/groups/public</url>
                  <snapshots>
                      <enabled>true</enabled>
                      <updatePolicy>always</updatePolicy>
                  </snapshots>
              </pluginRepository>
          </pluginRepositories>
      
      ![](https://image-static.segmentfault.com/232/997/2329976907-5d994ba6e9e77_articlex)
      
          <distributionManagement>
              <repository>
                  <id>releases</id>
                  <name>Nexus Release Repository</name>
                  <url>http://nexus.jetbrains.org.cn/nexus/content/repositories/releases/</url>
              </repository>
              <snapshotRepository>
                  <id>snapshots</id>
                  <name>Nexus Snapshot Repository</name>
                  <url>http://nexus.jetbrains.org.cn/nexus/content/repositories/snapshots/</url>
              </snapshotRepository>
          </distributionManagement>
備註: pom中上傳的設置id要與maven setting中的id保持一致。
  1. 項目執行mvn delepoy 便可上傳到私服。
  2. 至於releases庫與snaoshots庫的區別微信

    • 簡單去說就是relesses庫是穩定版本或者生產版本,snaoshots庫是不穩定版本或開發版本,項目版本號後面帶

-SNAPSHOT 的都會上傳到snaoshots庫。less

備註

若是以爲中央倉庫慢的話,能夠用個人私服 只須要配置 repositories 標籤中的內容,下載 依賴, distributionManagement 標籤中的內容爲 上傳, 無需配置,也不對外開放上傳權限。maven

如但願瞭解更多,請關注微信公衆號
url

相關文章
相關標籤/搜索