maven setting多倉庫配置方式
前言
maven setting 通常公司都有私 服地址,但不是所有包私 服上都有,這時就要用阿里云或者其他地址去拉包。
那么我們可以直接設(shè)置setting 使其拉包時第一個地址拉取不到自動到第二個地址拉取以此類推可設(shè)置多個倉庫地址進行補充。
一 、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>
<!-- 也可以把阿里云等倉庫地址直接在這里補充 -->
<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 默認有一個setting文件,如果我們的setting文件有很多,而默認setting中的mirror 直接指定了倉庫路徑,此時無論引用哪個setting文件,都會首先到默認setting內(nèi)指定的倉庫中拉取。
如下圖所示,我的默認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)文章
java Spring MVC4環(huán)境搭建實例詳解(步驟)
spring WEB MVC框架提供了一個MVC(model-view-controller)模型-視圖-控制器的結(jié)構(gòu)和組件,利用它可以開發(fā)更靈活、松耦合的web應(yīng)用。MVC模式使得整個服務(wù)應(yīng)用的各部分(控制邏輯、業(yè)務(wù)邏輯、UI界面展示)分離開來,使它們之間的耦合性更低2017-08-08
Java SpringBoot啟動指定profile的8種方式詳解
這篇文章主要介紹了spring boot 如何指定profile啟動的操作,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-09-09
IntelliJ IDEA 好用插件之a(chǎn)nalyze inspect code詳解
這篇文章主要介紹了IntelliJ IDEA 好用插件之a(chǎn)nalyze inspect code的相關(guān)知識,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2020-12-12

