nexus本地maven仓库部署及下载
部署環境:
系統版本:Mac os 12.0.1
Nexus版本:3.37.3
1.下載Nexus安裝包下載地址
跟據自己的設備下載合適的安裝包版本
Unix archive:linux
Windows archive:windows
OSX archive:mac os
2.啟動Nexus
找到安裝包路徑
你的文件目錄/nexus-3.37.3-02/bin
打開cmd進入到安裝包下的bin目錄啟動你的nexus
看到如下字樣,則表啟動成功
3.訪問Nexus
不知道你的nexus訪問地址?沒關系,我教你。
你的文件目錄/nexus-3.37.3-02/etc/nexus-default.properties
在這里是你的nexus配置文件
打開配置文件
application-port=訪問Nexus端口號(默認8081)
application-host=訪問Nexus的ip地址(默認localhost本地ip)
所以你的訪問路徑就是 http://localhost:8081
看到如下圖則表示啟動成功
4.登錄Nexus
到這里肯定有人會問,我不知道賬號密碼,怎么辦。
很多文章會告訴你,賬號是admin,密碼是admin123
但是,那是舊版本的Nexus,賬號依然是admin,新版本的密碼可不是,別瞎說。
你的文件目錄/nexus-3.37.3-02/etc/sonatype-work/nexus3/admin.password
提示:我這里已經修改過了密碼,所以admin.password就消失了
打開文件,直接復制密碼登錄即可,登錄成功之后會讓你再輸入一次密碼,這是修改密碼的步驟,以后將用這個密碼登錄Nexus。
5.打包Jar上傳到Nexus
1)全局配置Nexus
找到maven安裝目錄
文件路徑/maven/版本號/libexec/conf/settings.xml
2)servers節點
<server><!-- 發布版本--><id>nexus</id> <!-- 隨意填寫,但項目中repository的id得與這里一致--><username>admin</username> <!-- 賬戶--><password>admin123</password> <!-- 密碼--></server><server><!-- 發布版本--><id>nexus-releases</id> <!-- 隨意填寫,但項目中repository的id得與這里一致--><username>admin</username> <!-- 賬戶--><password>admin123</password> <!-- 密碼--></server><server><!-- 發布版本--><id>nexus-snapshots</id> <!-- 隨意填寫,但項目中repository的id得與這里一致--><username>admin</username> <!-- 賬戶--><password>admin123</password> <!-- 密碼--></server>3)mirrors節點
<mirror><id>nexus</id><!--表示訪問哪些工廠時需要使用鏡像--><mirrorOf>*</mirrorOf><url>http://localhost:8081/repository/maven-public/</url></mirror>6.打包上傳Jar
這里以vscode為例子,其他開發工具大同小異
1)pom.xml配置你的Nexus倉庫地址信息
<!-- 本地nexus私有庫--><distributionManagement><snapshotRepository><id>nexus-snapshots</id><url>http://localhost:80801/repository/maven-snapshots/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></snapshotRepository><repository><id>nexus-releases</id><url>http://localhost:80801/repository/maven-releases/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></distributionManagement>2)在終端cmd輸入mvn clean
3)在終端cmd輸入mvn deploy
看到BUILD SUCCESS字樣則代表上傳成功。
回到Nexus查看上傳的jar
在這里即可以看到剛才上傳的jar文件(別糾結我的為什么那么多個,因為我之前就上傳了好幾個)
7.引用Nexus庫jar
找到maven安裝目錄
文件路徑/maven/版本號/libexec/conf/settings.xml
1)profiles節點
<profile><!--profile 的 id--><id>nexus</id><repositories><repository><!--倉庫 id,repositories 可以配置多個倉庫,保證 id 不重復--><id>nexus</id><!--倉庫地址,即 nexus 倉庫組的地址--><url>http://localhost:8081/repository/maven-public/</url><!--是否下載 releases 構件--><releases><enabled>true</enabled></releases><!--是否下載 snapshots 構件--><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><!-- 插件倉庫,maven 的運行依賴插件,也需要從私服下載插件 --><pluginRepository><!-- 插件倉庫的 id 不允許重復,如果重復后邊配置會覆蓋前邊 --><id>public</id><name>Public Repositories</name><url>http://localhost:8081/repository/maven-public/</url><!--是否下載 releases 構件--><releases><enabled>true</enabled></releases><!--是否下載 snapshots 構件--><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile>2)activeProfiles節點
激活配置
<activeProfiles><activeProfile>nexus</activeProfile></activeProfiles>到這里,你的項目已經可以正常使用Nexus了。
end
總結
以上是生活随笔為你收集整理的nexus本地maven仓库部署及下载的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: spring cloud 总结
- 下一篇: 工程代码_Egret开发笔记(二)基础工