maven setting多倉庫配置方式
前言
maven setting 通常公司都有私 服地址,但不是所有包私 服上都有,這時就要用阿里云或者其他地址去拉包。
那么我們可以直接設(shè)置setting 使其拉包時第一個地址拉取不到自動到第二個地址拉取以此類推可設(shè)置多個倉庫地址進(jìn)行補(bǔ)充。
一 、setting文件
<?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">
<localRepository>D:\software\dev\apache-maven-3.6.3\Repositories</localRepository>
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers></servers>
<mirrors></mirrors>
<profiles>
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>private</id>
<repositories>
<repository>
<id>maven-releases</id>
<name>User Porject Release</name>
<url>http://私服 地址/nexus/repository/maven-releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>maven-snapshots</id>
<name>User Porject Snapshot</name>
<url>http://私服 地址/nexus/repository/maven-snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<!-- 也可以把阿里云等倉庫地址直接在這里補(bǔ)充 -->
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.cn/repository/maven-public/</url>
</repository>
</repositories>
</profile>
<!-- <profile>-->
<!-- <id>repo1</id>-->
<!-- <repositories>-->
<!-- <repository>-->
<!-- <id>repo1</id>-->
<!-- <url>https://repo1.maven.org/maven2</url>-->
<!-- <releases>-->
<!-- <enabled>true</enabled>-->
<!-- </releases>-->
<!-- <snapshots>-->
<!-- <enabled>true</enabled>-->
<!-- <updatePolicy>always</updatePolicy>-->
<!-- </snapshots>-->
<!-- </repository>-->
<!-- </repositories>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>repo2</id>-->
<!-- <repositories>-->
<!-- <repository>-->
<!-- <id>repo2</id>-->
<!-- <url>https://repo2.maven.org/maven2</url>-->
<!-- <releases>-->
<!-- <enabled>true</enabled>-->
<!-- </releases>-->
<!-- <snapshots>-->
<!-- <enabled>true</enabled>-->
<!-- <updatePolicy>always</updatePolicy>-->
<!-- </snapshots>-->
<!-- </repository>-->
<!-- </repositories>-->
<!-- </profile>-->
</profiles>
<activeProfiles>
<activeProfile>aliyun</activeProfile>
<activeProfile>private</activeProfile>
<!-- <activeProfile>repo1</activeProfile>-->
<!-- <activeProfile>repo2</activeProfile>-->
</activeProfiles>
</settings>
二、其他問題
1.maven 默認(rèn)有一個setting文件,如果我們的setting文件有很多,而默認(rèn)setting中的mirror 直接指定了倉庫路徑,此時無論引用哪個setting文件,都會首先到默認(rèn)setting內(nèi)指定的倉庫中拉取。
如下圖所示,我的默認(rèn)setting文件如此設(shè)置后,我指定了另外的setting文件,但是他會去D:\software\dev\apache-maven-3.6.3\Repositories\hlj路徑下尋包
尋找不到直接報錯
Could not find artifact xxx in public (file://D:\software\dev\apache-maven-3.6.3\Repositories\hlj)
最好只保留一個setting文件


總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Spring?Cloud?Gateway實現(xiàn)分布式限流和熔斷降級的示例代碼
這篇文章主要介紹了Spring?Cloud?Gateway實現(xiàn)分布式限流和熔斷降級的示例代碼,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2025-06-06
使用Springboot實現(xiàn)OAuth服務(wù)的示例詳解
OAuth(Open Authorization)是一個開放標(biāo)準(zhǔn),用于授權(quán)第三方應(yīng)用程序訪問用戶資源,而不需要共享用戶憑證。本文主要介紹了如何使用Springboot實現(xiàn)一個OAuth服務(wù),需要的可以參考一下2023-05-05
SpringBoot實現(xiàn)聯(lián)表查詢的代碼詳解
這篇文章主要介紹了SpringBoot中如何實現(xiàn)聯(lián)表查詢,文中通過代碼示例和圖文結(jié)合的方式講解的非常詳細(xì),對大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下2024-05-05
IDEA提示 add *** to custom tags問題及解決
文章介紹了如何在文檔注釋中添加自定義注解(@xxx),并提供了添加和刪除注解的方法,總結(jié)了個人經(jīng)驗,希望對大家有所幫助2024-12-12
springcloud?gateway高級功能之集成apollo后動態(tài)刷新路由方式
這篇文章主要介紹了springcloud?gateway高級功能之集成apollo后動態(tài)刷新路由方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-08-08
最簡單的在IntelliJ IDEA導(dǎo)入一個本地項目教程(圖文)
這篇文章主要介紹了最簡單的在IntelliJ IDEA導(dǎo)入一個本地項目教程(圖文),文中通過圖文介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08

