1 Nexus介紹
Nexus是Maven倉庫管理器潜圃,如果你使用Maven缸棵,你可以從Maven中央倉庫 下載所需要的構(gòu)件(artifact),但這通常不是一個好的做法谭期,你應(yīng)該在本地架設(shè)一個Maven倉庫服務(wù)器堵第,在代理遠(yuǎn)程倉庫的同時維護本地倉庫,以節(jié)省帶寬和時間隧出,Nexus就可以滿足這樣的需要踏志。此外,他還提供了強大的倉庫管理功能胀瞪,構(gòu)件搜索功能针余,它基于REST,友好的UI是一個extjs的REST客戶端凄诞,它占用較少的內(nèi)存圆雁,基于簡單文件系統(tǒng)而非數(shù)據(jù)庫。這些優(yōu)點使其日趨成為最流行的Maven倉庫管理器帆谍。
2 下載地址
https://www.sonatype.com/download-oss-sonatype
3部署搭建
安裝jdk環(huán)境和nexus
[root@nexus ~]#: rpm -ivh jdk-8u212-linux-x64.rpm
[root@nexus ~]#: tar xf nexus-3.16.1-02-unix.tar.gz
[root@nexus ~]#: mv nexus-3.16.1-02 /data/nexus
啟動Nexus把整個硬盤作為存儲空間伪朽,硬盤空間越大nexus啟動越慢
[root@nexus ~]#: /data/nexus/bin/nexus start
[root@nexus ~]#: netstat -luntp
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 2282/java nexus的端口為8081啟動成功
4 介紹
這只倉庫,現(xiàn)在倉庫里應(yīng)該都沒有東西
第一個是代理的性質(zhì)的汛蝙,它會去中央倉庫下載
第二個公開的組
復(fù)制URL更改maven的配置文件
[root@jenkins ~]#: cd /usr/local/maven/conf/
[root@jenkins conf]#: vim settings.xml
找到 <servers> 標(biāo)簽烈涮,添加 Nexus 默認(rèn)認(rèn)證信息:
<server>
<id>my-nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>my-nexus-snapshot</id>
<username>admin</username>
<password>admin123</password>
</server>
找到 <mirrors> 標(biāo)簽朴肺,添加鏡像:
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
找到 <profiles> 標(biāo)簽,添加倉庫信息:
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
激活倉庫:
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
配置完成后保存坚洽,并重啟 nexus 服務(wù)
帶 <url>http://central</url>的信息都要改成剛才復(fù)制的地址
<url>http://10.0.0.22:8081/repository/maven-public/</url>
以后在需要依賴包宇挫,在nexus私服里找,沒有在會按照上面介紹的順序查找