Nexus 簡介
Nexus 是一個強大的依賴倉庫管理器,極大地簡化了內部倉庫的維護和外部倉庫的訪問,
2016 年 4 月 6 日 Nexus 3.0 版本發布,相較 2.x 版本 有了很大的改變:
- 對低層代碼進行了大規模重構,提升性能,增加可擴展性以及改善用戶體驗,
- 升級界面,極大的簡化了用戶界面的操作和管理
- 提供新的安裝包,讓部署更加簡單
- 提供新的管理介面,以及增強對自動任務的管理
安裝 Nexus
-
創建
docker-compose.ymlversion: '3.1' services: nexus: restart: always image: sonatype/nexus3 container_name: nexus ports: - 8081:8081 volumes: - /usr/local/docker/nexus/data:/nexus-data -
啟動容器
$ docker-compose up -d啟動時如果出現權限問題需要賦予資料卷目錄可讀可寫的權限
$ chmod 777 /usr/local/docker/nexus/data
登錄訪問 Nexus 頁面
訪問 http://{ip}:8081
- 初始賬號:admin
- 初始密碼在
/usr/local/docker/nexus/data/admin.password檔案中查看

Maven 配置 Nexus 認證資訊
-
修改 Maven 安裝目錄
conf中的settings.xml -
在
servers節點下配置 Nexus 私庫的賬號密碼:<server> <id>nexus-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password> </server>
專案中配置 Nexus
-
在 Maven 專案中的
pom.xml配置 Nexus 代理倉庫<repositories> <repository> <id>nexus</id> <name>Nexus Repository</name> <url>http://{host}:{port}/repository/maven-public/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>Nexus Plugin Repository</name> <url>http://{host}:{port}/repository/maven-public/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories> -
更新 Maven 配置,專案就可以從 Nexus 私服倉庫拉取依賴了
從 Nexus 中拉取依賴
完成以上配置并重繪配置資訊,即可從 Nexus 私庫中拉取依賴
部署第三方依賴到 Nexus
mvn deploy
END
- 文章作者:彭超
- 本文首發于個人博客:https://antoniopeng.com/2020/03/08/docker/%E4%BD%BF%E7%94%A8DockerCompose%E6%90%AD%E5%BB%BANexus%E4%BE%9D%E8%B5%96%E7%A7%81%E6%9C%8D%E5%8F%8A%E4%BD%BF%E7%94%A8%E9%85%8D%E7%BD%AE/
- 著作權宣告:本博客所有文章除特別宣告外,均采用 CC BY-NC-SA 4.0 許可協議,轉載請注明來自 彭超 | Blog!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/77800.html
標籤:其他
