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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

配置Maven使用Nexus

發布時間:2024/1/17 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 配置Maven使用Nexus 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

有兩種方式

第一種:最簡單明了的方式

直接在你項目的pom.xml中添加如下

? ? <repositories> ?

? ? ? ? <repository> ?

? ? ? ? ? ? <snapshots> ?

? ? ? ? ? ? ? ? <enabled>true</enabled> ?

? ? ? ? ? ? </snapshots> ?

? ? ? ? ? ? <id>public</id> ?

? ? ? ? ? ? <name>Public Repositories</name> ?

? ? ? ? ? ? <url>http://localhost:8081/nexus/content/groups/public/</url> ?

? ? ? ? </repository> ?

? ? </repositories> ?

? ? <pluginRepositories> ?

? ? ? ? <pluginRepository> ?

? ? ? ? ? ? <id>public</id> ?

? ? ? ? ? ? <name>Public Repositories</name> ?

? ? ? ? ? ? <url>http://localhost:8081/nexus/content/groups/public/</url> ?

? ? ? ? </pluginRepository> ?

? ? </pluginRepositories>

那么,maven會首先從你配置的公共倉庫中取信息,取不到再去默認的倉庫取

?

?

第二種: 配置稍復雜 ? ?

?

為了使用Nexus,你將要配置Maven去檢查Nexus而不是公共倉庫。為此,你需要需該Maven的mirror setting,該配置文件在~/.m2/settings.xml也有可能是Maven目下路conf/settings.xml.首先,我們演示如何配置Maven查閱你的Nexus而不是Maven Central repository。然后我們重寫central repository并驗證Nexus是工作的。

? ??配置Maven使用單個Nexus Group

? ? 如果你想更改Nexus用于內部開發,你應該配置一個包含了release版和snapshot的single nexus group。為此,你需要添加snapshot倉庫到你的public group,并且在你的Maven的settings.xml中添加如下內容:

<settings>

? <mirrors>

? ? <mirror>

? ? ? <!--This sends everything else to /public -->

? ? ? <id>nexus</id>

? ? ? <mirrorOf>*</mirrorOf>

? ? ? <url>http://localhost:8081/nexus/content/groups/public</url>

? ? </mirror>

</mirrors>

?

<profiles>

? <profile>

? ? <id>nexus</id>

? ? <!--Enable snapshots for the built in central repo to direct -->

? ? <!--all requests to nexus via the mirror -->

? ? <repositories>

? ? ? <repository>

? ? ? ? <id>central</id>

? ? ? ? <url>http://central</url>

? ? ? <releases>

? ? ? ? <enabled>true</enabled>

? ? ? </releases>

? ? ? <snapshots>

? ? ? ? <enabled>true</enabled>

? ? ? </snapshots>

? ? </repository>

? </repositories>

?

? <pluginRepositories>

? ? <pluginRepository>

? ? ? <id>central</id>

? ? ? <url>http://central</url>

? ? ? <releases>

? ? ? ? <enabled>true</enabled>

? ? ? </releases>

? ? ? <snapshots>

? ? ? ? <enabled>true</enabled>

? ?</snapshots>

? </pluginRepository>

</pluginRepositories>

</profile>

</profiles>

?

<activeProfiles>

<!--make the profile active all the time -->

<activeProfile>nexus</activeProfile>

</activeProfiles>

</settings>

在上面的配置信息中,我們定義了一個single group:nexus。 然后配置了repository以及pluginRepository并以id "central"命名,這個配置重寫了super pom的同名的倉庫。我們更改了倉庫讓其支持snapshots并且使用了偽造的URL替換了默認URL,這樣nexus group能夠包含release以及snapshot版的artifacts,并且maven可以使用它們。

?

? ??為Missing Denpendence添加一個自定義的倉庫

? ? 如果你曾經配置了maven settings.xml來列出nexus的public group里所有的倉庫,你可能遇到你的項目無法在本地nexus取得artifacts信息。這很有可能是因為你嘗試去構建在pom中定義的自定義倉庫或者snapshotRepository。

? ? 首先登陸nexus,默認的用戶名和密碼是admin/admin123,按圖示進行選擇:

?

在彈出框中選擇Proxy Repository,填寫表單后保存即可。

?

?

第二種方式也是nexus官方文檔的做法,但是我沒有配置成功,總是報無法找到xxx, 因為趕工期,也就暫時擱置不研究了。

?

?

轉載于:https://www.cnblogs.com/dycg/archive/2013/05/29/3106968.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的配置Maven使用Nexus的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。