nexus搭建私服maven倉庫
阿新 • • 發佈:2018-11-20
下載sonatype nexus repository manager 3.x oss版
下載地址:http://www.sonatype.com/download-oss-sonatype
安裝
windows版
進入bin目錄下執行: nexus.exe/install 此步驟會安裝nexus服務,可以到系統服務(cmd → services.msc)中檢視nexus服務是否存在
拿管理員許可權開啟cmd,再次執行
再執行nexus.exe/run啟動
linux版
解壓縮tar xvzf nexus-3.14.0-04-unix.tar.gz
進入bin目錄 執行./nexus run
出現上圖說明啟動成功
啟動後登入地址:http://localhost:8081
預設admin/admin123
讓所有的maven專案使用私庫
配置maven的settings.xml
<servers> <server> <id>maven-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>maven-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers> <mirrors> <mirror> <id>maven-public</id> <name>maven-public</name> <url>http://localhost:8081/repository/maven-public/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>maven-central</id> <url>http://localhost:8081/repository/maven-central/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>maven-central</id> <url>http://localhost:8081/repository/maven-central/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
對於單個專案配置使用私庫
配置maven的settings.xml
<servers> <server> <id>maven-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>maven-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers> <mirrors> <mirror> <id>maven-public</id> <name>maven-public</name> <url>http://localhost:8081/repository/maven-public/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors>
配置專案的pom.xml
<distributionManagement> <snapshotRepository> <id>maven-snapshots</id> <url>http://localhost:8081/repository/maven-snapshots/</url> </snapshotRepository> <repository> <id>maven-releases</id> <url>http://localhost:8081/repository/maven-releases/</url> </repository> </distributionManagement> <repositories> <repository> <id>maven-public</id> <url>http://localhost:8081/repository/maven-public/</url> </repository> </repositories>
將工程導為jar包上傳到私庫
對工程執行deploy -e命令
遇到問題
網上說要清理磁碟空間
我當時在下載,佔用很大記憶體,後來刪掉了,這個問題就沒了
參考:
https://blog.csdn.net/liumiaocn/article/details/61931847
https://blog.csdn.net/cuncaojin/article/details/81270897
https://help.sonatype.com/repomanager3/installation/installation-methods