當前位置:
首頁 >
Maven入门教程(十四)-Nexus3.X私服下载资源
發布時間:2024/3/12
36
豆豆
生活随笔
收集整理的這篇文章主要介紹了
Maven入门教程(十四)-Nexus3.X私服下载资源
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本章節主要講解如何將私服的資源下載到本地倉庫。
從圖中我們可以看到,當我們設置了私服后,系統會先在私服中查找是否有需要的資源,如果沒有則去遠程倉庫查找。
具體如何設置私服呢?步驟如下
首先我們需要在maven目錄下的config目錄下的setting.xml文件中配置私服信息
添加鏡像信息,將所有外網倉庫的請求指向私服:
?
<mirror><id>nexus</id><mirrorOf>*</mirrorOf><url>http://localhost:8081/repository/maven-public/</url></mirror>此處的url我們配置的是group類型的倉庫組
這樣我們的私服就會按照group倉庫組里配置的私服地址依次查找資源是否存在
?
添加倉庫的配置
?
<profile><id>nexus</id><!--所有請求均通過鏡像 --><repositories><repository><id>central</id><name>Central Repository</name><url>https://repo.maven.apache.org/maven2</url><layout>default</layout><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><url>https://repo.maven.apache.org/maven2</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots> </pluginRepository></pluginRepositories></profile>生效配置信息,activeProfile的值要和profile中的id內容一致
<activeProfiles><activeProfile>nexus</activeProfile></activeProfiles>這樣我們私服的配置就完成了,完整的setting.xml文件如下
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><pluginGroups></pluginGroups><proxies></proxies><servers> </servers><mirrors><mirror><id>nexus</id><mirrorOf>*</mirrorOf><url>http://localhost:8081/repository/maven-public/</url></mirror></mirrors><profiles><profile><id>nexus</id><!--所有請求均通過鏡像 --><repositories><repository><id>central</id><name>Central Repository</name><url>https://repo.maven.apache.org/maven2</url><layout>default</layout><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><url>https://repo.maven.apache.org/maven2</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots> </pluginRepository></pluginRepositories></profile></profiles><activeProfiles><activeProfile>nexus</activeProfile></activeProfiles> </settings>?
總結
以上是生活随笔為你收集整理的Maven入门教程(十四)-Nexus3.X私服下载资源的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电子琴节奏包制作_制作MIDI电子音乐离
- 下一篇: linux开发板lcd按压,嵌入式Lin