天天看點

9.Nexus私服安裝配置

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

第二步:啟動tomcat

9.Nexus私服安裝配置

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

9.Nexus私服安裝配置

第五步:登入成功

9.Nexus私服安裝配置

第六步:點選views/repositories中repositories

9.Nexus私服安裝配置

nexus内置倉庫說明:

(1)maven

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

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

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

(4)3rd

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

(5)public

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

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

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

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

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

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

第八步:建立倉庫組

        點選public

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

9.Nexus私服安裝配置

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

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

<settings>

 <mirrors>

         <mirror>

                   <!--此處配置所有的建構均從私有倉庫中下載下傳

*代表所有,也可以寫central -->

                   <id>nexus</id>

                   <mirrorof>*</mirrorof>

                   <url>http://192.168.1.100:8000/nexus/content/groups/public</url>

         </mirror>

 </mirrors>

 <profiles>

         <profile>

                   <!—所有請求均通過鏡像

-->

                   <repositories>

                            <repository>

                                     <id>central</id>

                                     <url>http://central</url>

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

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

                            </repository>

                   </repositories>

                   <pluginrepositories>

                            <pluginrepository>

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

                            </pluginrepository>

                   </pluginrepositories>

         </profile>

 </profiles>

<activeprofiles>

 <!--make the profile active all the time-->

 <activeprofile>nexus</activeprofile>

 </activeprofiles>

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

<distributionmanagement>

        <repository>

           <id>releases</id>

           <name>internal releases</name>

           <url>http://localhost:8000/nexus/content/repositories/releases/</url>

        </repository>

        <snapshotrepository>

<id>snapshots</id>

           <name>internal snapshots</name>

           <url>http://localhost:8000/nexus/content/repositories/snapshots/</url>

        </snapshotrepository>

 </distributionmanagement>

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

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

 <servers>

       <server>

                 <id>releases </id>

<username>admin</username>

<password>admin123</password>

</server>

<server>

<id> snapshots </id>

 </server>

 </servers>