天天看點

Nexus私服搭建_01

nexus私服安裝

第一步:下載下傳nexus-webapp-2.9.0war包,然後拷貝到tomcat下的webapps目錄中

第二步:啟動tomcat

Nexus私服搭建_01

第四步:點選右上角“log in” ,輸入username:admin 和password:admin123登入

Nexus私服搭建_01

第五步:登入成功

Nexus私服搭建_01

第六步:點選views/repositories 中repositories

Nexus私服搭建_01

nexus内置倉庫說明:

(1)maven central:該倉庫代理maven中央倉庫,其政策為release,是以隻會下載下傳和緩存中央倉庫中的釋出版本構件。

(2)releases:這是一種政策為release的宿主類型倉庫,用來部署組織内部的釋出版本構件。

(3)snapshots:這是一個政策為snapshot的宿主類型倉庫,用來部署組織内部的快照版本構件。

(4)3rd party:這是一個政策為release的宿主類型倉庫,用來部署無法從公共倉庫獲得的第三方釋出版本構件。

(5)public repositories:該倉庫組将上述所有政策為release的倉庫聚合并通過一緻的位址提供服務。

第七步:建立宿主目錄和代理倉庫

· hosted:本地倉庫,通常我們會部署自己的構件到這一類型的倉庫。 

o 包括3rd party倉庫,releases倉庫,snapshots倉庫

· proxy:代理倉庫,它們被用來代理遠端的公共倉庫,如maven中央倉庫。 

· group:倉庫組,用來合并多個hosted/proxy倉庫,通常我們配置maven依賴倉庫組。 

第八步:建立倉庫組

點選public repositories倉庫,在configurations欄中選取需要合并的倉庫,點選箭頭加到左邊儲存即可

Nexus私服搭建_01

第九步:下載下傳index索引并進行建構搜尋(gav搜尋)

配置檔案和順序:maven_home/conf/setting.xml-à~/.m2/setting.xml-àproject

第十步:配置所有構件均從私服下載下傳,在~/.m2/setting.xml中配置如下:

Nexus私服搭建_01

<settings xmlns="http://maven.apache.org/settings/1.0.0"  

          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  

          xsi:schemalocation="http://maven.apache.org/settings/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  

  <mirrors>  

    <mirror>  

    <!--此處配置所有的建構均從私有倉庫中下載下傳 *代表所有,也可以寫central -->  

      <id>nexus</id>  

      <mirrorof>*</mirrorof>  

      <name>central repo</name>  

      <url>http://localhost:8089/nexus-2.9.0/content/groups/public/</url>  

    </mirror>  

  </mirrors>  

  <profiles>  

    <profile>  

        <id>nexus</id>  

        <repositories>  

            <repository>  

                <id>central</id>  

                <name>central</name>  

                <url>http://repo2.maven.org/maven2</url>  

                <releases><enabled>true</enabled></releases>  

                <snapshots><enabled>true</enabled></snapshots>  

            </repository>  

        </repositories>  

        <pluginrepositories>  

            <pluginrepository>  

            </pluginrepository>  

        </pluginrepositories>  

    </profile>  

  </profiles>  

  <activeprofiles>  

    <activeprofile>nexus</activeprofile>  

  </activeprofiles>  

</settings>  

第十一步:部署建構到nexus,包含release和snapshot, 在項目根目錄中pom.xml中配置:

Nexus私服搭建_01

<span style="font-family:microsoft yahei;font-size:12px;"><distributionmanagement>  

        <repository>  

            <id>releases</id>  

            <name>internal releases</name>  

            <url>http://localhost:8080/nexus-2.9.0/content/repositories/releases/</url>  

        </repository>  

        <snapshotrepository>  

            <id>snapshots</id>  

            <name>internal snapshots</name>  

            <url>http://localhost:8080/nexus-2.9.0/content/repositories/snapshots/</url>  

        </snapshotrepository>  

    </distributionmanagement></span>  

第十二步:nexus的通路權限控制,在~/m2/setting.xml中配置如下:

<!-- 設定釋出時的使用者名 -->

Nexus私服搭建_01

<span style="font-family:microsoft yahei;font-size:12px;"><servers>  

    <server>  

        <id>releases</id>  

        <username>admin</username>  

        <password>admin123</password>  

    </server>  

        <id>snapshots</id>  

  </servers></span>