07 maven私服的搭建nexus

 
 
maven私服的搭建nexus
 
 
1.nexus介紹:
Nexus 是 Maven 倉庫管理器,通過 nexus 可以搭建 maven 倉庫
 
 
2.nexus安裝
 
1.解壓 nexus-2.12.0-01-bundle.zip
2.
 
3.以管理員權限打開cmd(注意必須以管理員身份)
 
4.安裝成功
 
3.卸載nexus
1.以管理員權限運行cmd,進入 nexus 的 bin目錄,執行:nexus.bat uninstall
2.查看 window 服務列表 nexus 已被刪除。
 
4.啓動nexus
1.查看 nexus 的配置文件conf/nexus.properties
2.配置文件
# Jetty section
application-port=8081 # nexus 的訪問端口配置
application-host=0.0.0.0 # nexus 主機監聽配置(不用修改)
nexus-webapp=${bundleBasedir}/nexus # nexus 工程目錄
nexus-webapp-context-path=/nexus  # nexus 的 web 訪問路徑
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus # nexus 倉庫目錄runtime=${bundleBasedir}/nexus/WEB-INF # nexus 運行程序目錄
 
4.登錄
使用 Nexus 內置賬戶admin/admin123 登陸:
點擊右上角的 Log in,輸入賬號和密碼 登陸
 
5.倉庫的的類型
 
1.  hosted,宿主倉庫,部署自己的 jar 到這個類型的倉庫,包括 releases 和 snapshot 兩部
分,Releases公司內部發布版本倉庫、 Snapshots 公司內部測試版本倉庫
2.  proxy,代理倉庫,用於代理遠程的公共倉庫,如 maven 中央倉庫,用戶連接私服,私
服自動去中央倉庫下載 jar 包或者插件。
3.  group,倉庫組,用來合併多個 hosted/proxy 倉庫,通常我們配置自己的 maven 連接倉
庫組。
4.  virtual(虛擬):兼容 Maven1 版本的 jar 或者插件
 
 
nexus 倉庫默認在 sonatype-work 目錄中:
 
 
 
apache-snapshots :代理倉庫
存儲 snapshots 構件,代理地址 https://repository.apache.org/snapshots/
central :代理倉庫, 代理中央倉庫
central-m1 :virtual 類型倉庫,兼容 Maven1 版本的 jar 或者插件
releases : 本地倉庫,存儲 releases 構件。(正式用jar包)
snapshots : 本地倉庫,存儲 snapshots 構件。(測試用jar包)
thirdparty :第三方倉庫
public:倉庫組
6.將jar包發佈到私服
1.需要在客戶端即部署 ssm_dao工程的電腦上配置 maven環境,並 修改 settings.xml
文件,配置連接私服的用戶和密碼 。
2.在settings.xml中配置
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
 
3.配置項目 pom.xml
配置私服倉庫的地址,本公司的自己的 jar 包會上傳到私服的宿主倉庫,根據工程的版本號
決定上傳到哪個宿主倉庫,如果版本爲 release 則上傳到私服的 release 倉庫,如果版本爲
snapshot 則上傳到私服的 snapshot倉庫
 
 
<distributionManagement>
<repository>
<id>releases</id>
</repository>
<snapshotRepository>
<id>snapshots</id>
</snapshotRepository>
</distributionManagement>
注意:pom.xml 這裏<id> 和 settings.xml 配置 <id> 對應!
 
releases 連接發佈版本項目倉庫
snapshots 連接測試版本項目倉庫
 
 
 
 
 
 
 
 
 
 
 
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章