日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

配置Maven从私服下载构件

發(fā)布時間:2024/3/12 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 配置Maven从私服下载构件 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

--------------------siwuxie095

??

??

??

??

??

??

??

??

??

配置?Maven?從私服下載構件

??

??

從?Nexus 私服下載構件的配置方法共有三種

??

1法一

??

在?pom.xml 的 project 標簽中添加如下內(nèi)容

??

<repositories>

<repository>

?

<id>nexus</id>

<name>Nexus</name>

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

?

<releases>

<enabled>true</enabled>

</releases>

?

<snapshots>

<enabled>true</enabled>

</snapshots>

?

</repository>

</repositories>

?

<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

?

<pluginRepositories>

<pluginRepository>

?

<id>nexus</id>

<name>Nexus</name>

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

?

<releases>

<enabled>true</enabled>

</releases>

?

<snapshots>

<enabled>true</enabled>

</snapshots>

?

</pluginRepository>

</pluginRepositories>

??

注:分別配置倉庫和插件倉庫

??

??

??

??

2法二

??

1)在?settings.xml 的 profiles 標簽中添加如下內(nèi)容

??

<profile>

?

<id>nexus</id>

??

<repositories>

<repository>

??

<id>nexus</id>

<name>Nexus</name>

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

?

<releases>

<enabled>true</enabled>

</releases>

?

<snapshots>

<enabled>true</enabled>

</snapshots>

??

</repository>

</repositories>

??

<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

??

<pluginRepositories>

<pluginRepository>

??

<id>nexus</id>

<name>Nexus</name>

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

??

<releases>

<enabled>true</enabled>

</releases>

?

<snapshots>

<enabled>true</enabled>

</snapshots>

??

</pluginRepository>

</pluginRepositories>

??

</profile>

??

注:使用?id 為 nexus 的 profile 分別配置倉庫和插件倉庫

??

??

??

2)在?settings.xml 的 activeProfiles 標簽中添加如下內(nèi)容

??

<activeProfile>nexus</activeProfile>

??

注:將?id 為 nexus 的 profile 激活

??

??

??

??

3法三(建議):

??

1)在?settings.xml 的 mirrors 標簽中添加如下內(nèi)容

??

<mirror>

<id>nexus</id>

<name>Nexus</name>

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

<mirrorOf>*</mirrorOf>

</mirror>

??

注:配置一個匹配任何倉庫的鏡像,其地址為?Nexus 私服

??

??

??

2)在?settings.xml 的 profiles 標簽中添加如下內(nèi)容

??

<profile>

?

<id>nexus</id>

??

<repositories>

<repository>

??

<id>central</id>

<name>Central</name>

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

?

<releases>

<enabled>true</enabled>

</releases>

?

<snapshots>

<enabled>true</enabled>

</snapshots>

??

</repository>

</repositories>

??

<!-- ++++++++++++++++++++++++++ -->

??

<pluginRepositories>

<pluginRepository>

??

<id>central</id>

<name>Central</name>

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

??

<releases>

<enabled>true</enabled>

</releases>

?

<snapshots>

<enabled>true</enabled>

</snapshots>

??

</pluginRepository>

</pluginRepositories>

??

</profile>

??

注:使用?id 為 nexus 的 profile 分別配置倉庫和插件倉庫,

但倉庫和插件倉庫的?id 都為 central,這將覆蓋超級 POM

中央倉庫的配置,而 url 已無關緊要,因為所有的請求都會

通過鏡像訪問私服地址

??

配置倉庫和插件倉庫的主要目的是開啟對快照版本構件下載

的支持

??

??

??

3)在?settings.xml 的 activeProfiles 標簽中添加如下內(nèi)容

??

<activeProfile>nexus</activeProfile>

??

注:將?id 為 nexus 的 profile 激活

??

??

??

??

??

附:

??

法一

針對當前?Maven 項目

法二

針對所有?Maven 項目

法三

針對所有?Maven 項目

??

??

法二和法三雖然都可以一勞永逸,但法二除了從?Nexus 私服

下載構件之外,還會不時訪問中央倉庫

??

我們希望的是所有?Maven 下載請求都僅僅通過 Nexus 私服,

以全面發(fā)揮私服的作用,而法三剛好做到了這點

??

??

??

??

??

??

??

??

??

??

【made by siwuxie095】

總結

以上是生活随笔為你收集整理的配置Maven从私服下载构件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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