本文主要補充兩個主題:
1.手動更新索引
2.通過maven客戶端發布本地jar包到nexus
先說第一個主題:
由於maven中央倉庫匯集了全世界絕大多數的組件,所以它的索引庫非常龐大,在我們右擊倉庫update index時,經常是點擊了之后無反應。
這時候我們需要手動下載index文件,並上傳到nexus的索引目錄下。
操作步驟如下:
1.我們需要的文件如下:
2.第一個文件的來源如下:
http://download.csdn.net/detail/a3bbs/9552308
或
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.maven.indexer%22
第二個文件和第三個文件來源:
http://repo.maven.apache.org/maven2/.index/
3、把這幾個文件放在同一個文件路徑下面,從cmd進入到這個路徑,輸入命令:
java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer
執行完之后,會生成indexer目錄。
4、停止nexus進程。在linux下執行./nexus stop
5、將indexer下的所有內容都放到%nexus-home%\sonatype-work\nexus\indexer\central-ctx下面。
(我是在本地windows下執行,生成indexer后,上傳到linux對應目錄)
4、重新啟動nexus,進入管理界面,選擇central->Browse Index,就看到更新的索引了。
第二個主題:
1、在要發布到nexus的項目pom中,添加
<distributionManagement> <repository> <id>releases</id><!--這個ID需要與你的release倉庫的Repository ID一致--> <url>http://192.168.2.220:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id><!--這個ID需要與你的snapshots倉庫的Repository ID一致--> <url>http://192.168.2.220:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
上面的id與下圖箭頭標識處對應:
2、在maven的配置文件settings.xml中,添加
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers> <server> <id>releases</id> <username>admin</username> <password>admin123</password><!--這個密碼就是你設置的密碼--> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password><!--這個密碼就是你設置的密碼--> </server> </servers>
3、測試一下
在idea中的maven projects中,點擊deploy發布:
可以看到日志顯示:
在nexus上查看:
至此,兩個主題就到此結束了。
有問題可以留言回復。