nexus&maven使用


 

 

 

添加角色

 

 

添加本地jar到私有倉庫

 

上傳完成后可以在這查看

 

 

 Jar包更新

Nexus可以自動更新網絡上存在的jar包的索引,但是提供更新索引的網站是外國的,所以下載速度特別!特別!特別的慢!!!!不建議使用

然后Nexus就會自動開始慢的可憐的更新了
可以在這查看慢的可憐的更新情況,包括取消更新也慢的可憐

 

手動更新
手動更新需要下載好的索引,以及導入索引的配置文件和jar文件

鏈接: https://pan.baidu.com/s/1fwwq32Rjn3IzpjIMZKHvcQ
提取碼: nxs2

下載完成后將三個文件拷到linux系統下,然后使用指令生成索引文件
java -jar indexer-cli-5.1.0.jar -u nexus-maven-repository-index.gz -d indexer
解壓完成后的大小indexer

 

進入到nexus存儲空間中,刪除舊的索引
/usr/local/src/sonatype-work/nexus/indexer/central-ctx

 rm *

 

然后進到剛才解壓出來的indexer文件中,將全部文件復制到剛才的目錄下
路徑根據自己的實際情況適當修改
[root@nexus ~]# cd indexer
[root@nexus indexer]# ls
_4j.fdt _4j.fdx _4j.fnm _4j.frq _4j.nrm _4j.prx _4j.tii _4j.tis segments_2 segments.gen timestamp
[root@nexus indexer]# cp -r * /usr/local/src/sonatype-work/nexus/indexer/central-ctx/

 

完成后沒有提示信息,如果現實是否覆蓋,那就是你前面沒刪干凈
啟動Nexus
[root@nexus ~]# cd /usr/local/src/nexus-2.14.14-01
[root@nexus nexus-2.14.14-01]# cd bin
[root@nexus bin]# ./nexus start

這樣索引就出現了

 

 

 配置本地項目引用私服

在工程pom.xml中添加

<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.103.16:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168. 103.16:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

修改本地$MAVEN_HOME\conf目錄下的settings.xml配置文件,添加如下配置\

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

在本地工程目錄下執行:
mvn deploy
所部署的包就自動上傳到了nexus安裝目錄下的

配置Maven從Nexus下載構件

在POM中配置Nexus私服,這樣的配置只對當前的Maven項目有效。
<!--指定Nexus的構件倉庫-->
<repositories>
<repository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://192.168. 103.16:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!--指定Nexus的插件倉庫-->
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://192.168. 103.16:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

在settings.xml中配置profile元素,這樣就能讓本機所有的Maven項目都使用自己的Maven私服
<properties>
<repository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://192.168.103.16:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<br>
</properties>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM