日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Maven精选系列--私库搭建及使用

發(fā)布時間:2023/12/3 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Maven精选系列--私库搭建及使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

轉(zhuǎn)載自?Maven精選系列--私庫搭建及使用

為什么要使用私庫


maven默認(rèn)去遠(yuǎn)程中央倉庫下載JAR包的,訪問國外網(wǎng)絡(luò)相當(dāng)慢,如果團(tuán)隊每個人都去下載一遍無疑是網(wǎng)絡(luò)的浪費,當(dāng)然也可以添加國內(nèi)的鏡像,如阿里的比較穩(wěn)定,但如果想添加遠(yuǎn)程不存在的像第三方公司的JAR包就比較麻煩。


所以,使用私庫,第一,開源包只要有一個人下載過其他人就不需要再下載了,直接從私庫下載即可。第二,可以用來管理第三方公司的或者遠(yuǎn)程倉庫不存在的JAR包,或者公司不開源的JAR包。


推薦國內(nèi)穩(wěn)定的鏡像,如阿里的

http://maven.aliyun.com/nexus/content/groups/public/


nexus下載安裝


首先去sonatype官網(wǎng)下載nexus包,要下載開源免費版的OSS版,即Open Source Software。


https://www.sonatype.com/nexus-repository-oss



下載最新的3.X的版本,這里以windows為例進(jìn)行下載。


下載后點擊bin目錄中的啟動文件即可,默認(rèn)的端口是8081,訪問路徑是/,也可以去配置文件中修改,這里以默認(rèn)。


啟動后,打開localhost:8081,nexus默認(rèn)的用戶名是admin/admin123


默認(rèn)安裝有以下這幾個倉庫,在控制臺也可以修改遠(yuǎn)程倉庫的地址,第三方倉庫等。



Maven配置


修改maven主目錄conf/setting.xml配置文件。


添加nexus認(rèn)證的用戶名和密碼配置信息。


<servers>

????<server>

????? ? ? <id>nexus-releases</id>

????? ? ? <privateKey>admin</privateKey>

????? ? ? <passphrase>admin123</passphrase>

????</server>

????<server>

????? ? ? <id>nexus-snapshots</id>

????? ? ? <privateKey>admin</privateKey>

????? ? ? <passphrase>admin123</passphrase>

????</server>

</servers>


添加mirror鏡像


?<mirrors>

????<mirror>

????? ? ? <id>Nexus</id>

????? ? ? <mirrorOf>*</mirrorOf>

????? ? ? <name>Nexus</name>

????? ? ? <url>http://127.0.0.1:8081/repository/maven-public/</url>

?????</mirror>

? </mirrors>


添加私庫


<profiles>

<profile>

<id>Nexus</id>

<repositories>

<repository>

<id>Nexus</id>

<name>Nexus</name>

<url>http://127.0.0.1:8081/repository/maven-public/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</repository>

</repositories>

<pluginRepositories>

<pluginRepository>

<id>Nexus</id>

<name>Nexus</name>

<url>http://127.0.0.1:8081/repository/maven-public/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</pluginRepository>

</pluginRepositories>

</profile>

</profiles>

??

激活私庫


<activeProfiles>

???? <activeProfile>Nexus</activeProfile>

</activeProfiles>


發(fā)布到私庫



在pom配置文件中添加


<!-- nexus-releases nexus-snapshots與settings.xml中server下的id對應(yīng) -->

<distributionManagement>

<repository>

<id>nexus-releases</id>

<name>Nexus Releases Repository</name>

<url>http://localhost:8081/nexus/content/repositories/releases/</url>

</repository>

<snapshotRepository>

<id>nexus-snapshots</id>

<name>Nexus Snapshots Repository</name>

<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>

</snapshotRepository>

</distributionManagement>


在項目上使用命令mvn deploy打包就能發(fā)布到私庫。


創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的Maven精选系列--私库搭建及使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。