maven私服 nexus 的安裝與使用

簡介

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

要求

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

安裝

  1. 這裏咱們使用docker進行安裝,crt鏈接到vps
  2. yum -y install docker
![](https://user-gold-cdn.xitu.io/2019/10/6/16d9eccc0c1ea1c6?w=489&h=225&f=png&s=18470)複製代碼
  1. 啓動docker: service docker start
  2. 查找nexus鏡像 : docker search nexus

  1. 通常狀況下,咱們都是用stars最高的。docker pull docker.io/sonatype/nexus
  2. 啓動nexus容器,對於之後的容器啓動,[不清楚如何啓動能夠去docker hub 查看][https://hub.docker.com/],
![](https://user-gold-cdn.xitu.io/2019/10/6/16d9eccc9a1a2510?w=784&h=587&f=png&s=38523)複製代碼
  1. 通常直接搜索run 就能夠找到如何啓動
![](https://user-gold-cdn.xitu.io/2019/10/6/16d9ecccd3ecdea9?w=580&h=81&f=png&s=5499)複製代碼
  1. 訪問查看,管理員帳戶密碼 admin admin123
![](https://user-gold-cdn.xitu.io/2019/10/6/16d9eccd0cf6d3d6?w=1366&h=654&f=png&s=91312)複製代碼
  1. maven設置
* setting.xml設置
        ![](https://user-gold-cdn.xitu.io/2019/10/6/16d9eccd3c2d9040?w=242&h=303&f=png&s=10027)複製代碼
* pom文件設置複製代碼
![](https://user-gold-cdn.xitu.io/2019/10/6/16d9eccd6b86c9fc?w=485&h=466&f=png&s=36778)複製代碼
<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://user-gold-cdn.xitu.io/2019/10/6/16d9eccd9f88a79b?w=547&h=263&f=png&s=24780)複製代碼
<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庫。

備註

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

如但願瞭解更多,請關注微信公衆號
相關文章
相關標籤/搜索