1. 程式人生 > >1107_Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-2.Nexus倉庫設定,手動更新索引,自動更新索引

1107_Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-2.Nexus倉庫設定,手動更新索引,自動更新索引

Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-2.Nexus倉庫設定,手動更新索引,自動更新索引

2018年08月27日 17:30:53 weixin_42828741 閱讀數:64

還未安裝的可閱讀以下文章:
Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-1.安裝配置
https://blog.csdn.net/weixin_42828741/article/details/82112360

還未更新索引的可閱讀以下文章:
Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-2.Nexus倉庫設定,手動更新索引,自動更新索引
https://blog.csdn.net/weixin_42828741/article/details/82116396

不懂如何手動上傳第三方構件的閱讀以下文章:
Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-3.手動上傳到第三方構件3rd party
https://blog.csdn.net/weixin_42828741/article/details/82117331

不懂如何自動將專案相關資源上傳發布到Nexus相關庫中的閱讀以下文章:
Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-4.自動將專案相關資源上傳發布到Nexus相關庫這個中
https://blog.csdn.net/weixin_42828741/article/details/82117900

想從Nexus下載構件的閱讀以下文章:
Linux系統下如何安裝Nexus(使用Nexus搭建Maven私服)-5.從Nexus倉庫下載構件

https://blog.csdn.net/weixin_42828741/article/details/82119122

1.登入Nexus(預設使用者名稱密碼:admin/admin123)

自動更新索引(適用於網路良好的小夥伴)

2.登入後點擊左側導航欄的Repositories,點選Central(Maven的中央倉庫,預設不會下載index索引檔案),點選Configuration,找到Download Remote Indexes將預設值改為true並儲存
這裡寫圖片描述

3.點選如下框中任意一項便可開始自動更新
這裡寫圖片描述

4.點選Browse Index,點選refresh,所看到的即是更新的
這裡寫圖片描述

手動更新索引(適用於網路一般的小夥伴)

2.到索引網站下載所需索引檔案(總共三個檔案)
在這個網站下載兩個檔案:repo.maven.apache.org/maven2/.index
按control+f6搜尋:nexus-maven-repository-index.gz

下載:
(1)nexus-maven-repository-index.gz
(2)nexus-maven-repository-index.properties
這裡寫圖片描述

在這個網站下載一個檔案:maven.outofmemory.cn/org.apache.maven.indexer/indexer-cli/5.1.0/
下載:
(3)indexer-cli-5.1.0.jar
這裡寫圖片描述

3.Linux下的Nexus資料夾(如未配置可參考本文開頭連結)下建立index資料夾,並將三個檔案放入。
如果是從前一篇文章跟過來的,直接在終端機輸入如下程式碼

[[email protected] nexus-2.12.0-01]# cd bin/
[[email protected] bin]# cd ..
[[email protected] nexus-2.12.0-01]# cd ..
[[email protected] nexus2.12]# ls
index  nexus-2.12.0-01  nexus-2.12.0-01-bundle.tar.gz  sonatype-work
[[email protected] nexus2.12]# cd index/
[[email protected] index]# ls
indexer-cli-5.1.0.jar            nexus-maven-repository-index.properties
nexus-maven-repository-index.gz
[[email protected] index]# java -jar indexer-cli-5.1.0.jar  -u nexus-maven-repository-index.gz -d indexer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

如果不是的則自行用終端進入index,輸入如下程式碼,回車(解壓檔案需等待一些時間,猶豫檔案較大,虛擬機器一定要注意留出足夠的空間
[[email protected]st index]# java -jar indexer-cli-5.1.0.jar -u nexus-maven-repository-index.gz -d indexer
這裡寫圖片描述

4.關閉nexus,刪除原有的索引檔案
(1-1)如果按照上面操作的,則直接在終端機輸入如下程式碼關閉nexus

[[email protected] index]# cd ..
[[email protected] nexus2.12]# ls
index  nexus-2.12.0-01  nexus-2.12.0-01-bundle.tar.gz  sonatype-work
[[email protected] nexus2.12]# cd nexus-2.12.0-01
[[email protected] nexus-2.12.0-01]# cd bin/
[[email protected] bin]# ./nexus stop
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

(1-2)如果不是的則通過終端機找到nexus的bin並進入,然後輸入如下程式碼關閉nexus

[[email protected] bin]# ./nexus stop
  • 1

(2-1)如果按照上面操作的,則直接在終端機輸入如下程式碼刪除原有索引

[[email protected] bin]# cd ..
[[email protected] nexus-2.12.0-01]# cd ..
[[email protected] nexus2.12]# ls
index  nexus-2.12.0-01  nexus-2.12.0-01-bundle.tar.gz  sonatype-work
[[email protected] nexus2.12]# cd sonatype-work/
[[email protected] sonatype-work]# cd nexus/
[[email protected] nexus]# cd indexer/
[[email protected] indexer]# cd central-ctx/
[[email protected] central-ctx]# ls
_0.cfs  segments_2  segments.gen
[[email protected] central-ctx]# rm *
rm:是否刪除普通檔案 "_0.cfs"?y(全部輸入y)
rm:是否刪除普通檔案 "segments_2"?y
rm:是否刪除普通檔案 "segments.gen"?y

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

(2-2)如果不是的則通過終端機找到indexer的central-ctx並進入,然後輸入如下程式碼刪除原有索引

[[email protected] central-ctx]# rm *
rm:是否刪除普通檔案 "_0.cfs"?y(全部輸入y)
rm:是否刪除普通檔案 "segments_2"?y
rm:是否刪除普通檔案 "segments.gen"?y
  • 1
  • 2
  • 3
  • 4

5.將之前解壓好的檔案全部拷貝到sonatype-work/nexus/indexer/central-ctx/
在終端中輸入如下程式碼
[[email protected] indexer]# cp -r * /home/monkey/software/nexus2.12/sonatype-work/nexus/indexer/central-ctx

6.啟動nexus進行自動更新索引
輸入如下程式碼啟動:

[[email protected] bin]# ./nexus start
  • 1

成功後通過瀏覽器開啟nexus,點選刷需即可看到索引已經自動更新啦!