天天看點

nexus-私服的入門使用

作者:bobo棒

1.1 結構圖

nexus-私服的入門使用
nexus-私服的入門使用

使用場景

1.2 安裝私服軟體

1.2.1 目錄介紹

該軟體存放到一個沒有中文的目錄裡面。

nexus-私服的入門使用

裡面有兩個目錄

nexus-私服的入門使用

1.2.2 軟體安裝

A)第一步:

nexus-私服的入門使用

B)第二步

nexus-私服的入門使用

1.2.3啟動nexus

nexus-私服的入門使用

出現下圖,表示啟動成功

nexus-私服的入門使用

1.2.4 通路

A)第一步

nexus-私服的入門使用

B)第二步 通路密碼

nexus-私服的入門使用

輸入密碼:

更改随機密碼:

nexus-私服的入門使用
nexus-私服的入門使用
nexus-私服的入門使用

1.2.5 倉庫類型

包含四種倉庫類型

Virtual 虛拟倉庫 ,不使用

Proxy 代理倉庫 被用來代理遠端的公共倉庫,如maven中央倉庫

Hosted 宿主/本地倉庫 ,通常我們會部署自己的構件到這一類型的倉庫。

Group 倉庫組 (常用),作用: 當下載下傳jar時有該group選擇從具體上邊那個倉庫下載下傳。

Releases:(穩定版)

這裡存放我們自己項目中釋出的建構, 通常是Release版本的, 比如我們自己做了一個FTP

Server的項目, 生成的構件為ftpserver.war,

我們就可以把這個建構釋出到Nexus的Releases本地倉庫. 關于符合釋出後面會有介紹。

Snapshots:(快照版)

它的目的是讓我們可以釋出那些非release版本, 非穩定版本

2 釋出jar到私服

2.1 配置maven settings.xml

<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>           

2.2 在要釋出的項目pom.xml 配置如下内容

<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/repository/${改成倉庫名稱}/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/repository/maven/${改成倉庫名稱}</url>
</snapshotRepository>
</distributionManagement>           

2.3 點選項目釋出

nexus-私服的入門使用

2.4 檢視遠端倉庫

nexus-私服的入門使用
nexus-私服的入門使用
nexus-私服的入門使用
nexus-私服的入門使用

3 從私服下載下傳jar

3.1 開放權限

nexus-私服的入門使用

3.2 配置settings.xml

<profile> 
<!--profile的id-->
<id>dev</id> 
<repositories> 
<repository> 
<!--倉庫id,repositories可以配置多個倉庫,保證id不重複-->
<id>nexus</id> 
<!--倉庫位址,即nexus倉庫組的位址-->
<url>http://localhost:8081/repository/maven-public/</url> 
<!--是否下載下傳releases構件-->
<releases> 
<enabled>true</enabled> 
</releases> 
<!--是否下載下傳snapshots構件-->
<snapshots> 
<enabled>true</enabled> 
</snapshots> 
</repository> 
</repositories> 
<pluginRepositories> 
<!-- 插件倉庫,maven的運作依賴插件,也需要從私服下載下傳插件 -->
<pluginRepository> 
<!-- 插件倉庫的id不允許重複,如果重複後邊配置會覆寫前邊 -->
<id>public</id> 
<name>Public Repositories</name> 
<url>http://localhost:8081/repository/maven-public/</url> 
</pluginRepository> 
</pluginRepositories> 
</profile>           

激活配置

<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>           

3.4.删除本地倉庫的jar

nexus-私服的入門使用

3.5 單獨建立項目模拟另一個使用者

nexus-私服的入門使用

3.6 重新整理配置

重新整理能正常依賴,則表示成功

nexus-私服的入門使用