解讀maven配置阿里云鏡像問題
maven配置阿里云鏡像
打開maven配置文件,找到標(biāo)簽,添加如下:
<mirrors> ? <mirror>? ? ? <id>alimaven</id>? ? ? <name>aliyun maven</name>? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public/</url>? ? ? <mirrorOf>central</mirrorOf>? ? </mirror>? </mirrors>
設(shè)置全局的jdk,在配置文件配置如下:
<profile> ? ? ? <id>jdk18</id> ? ? ? <activation> ? ? ? ? ? <activeByDefault>true</activeByDefault> ? ? ? ? ? <jdk>1.8</jdk> ? ? ? </activation> ? ? ? <properties> ? ? ? ? ? <maven.compiler.source>1.8</maven.compiler.source> ? ? ? ? ? <maven.compiler.target>1.8</maven.compiler.target> ? ? ? ? ? <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> ? ? ? </properties> ?? </profile> ?
設(shè)置局部的jdk,在項(xiàng)目的pom,xml文件中添加如下build元素
<build> ? ? ? <plugins> ? ? ? ? ? <plugin> ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId> ? ? ? ? ? ? ? <artifactId>maven-compiler-plugin</artifactId> ? ? ? ? ? ? ? <configuration> ? ? ? ? ? ? ? ? ? <source>1.7</source> ? ? ? ? ? ? ? ? ? <target>1.7</target> ? ? ? ? ? ? ? </configuration> ? ? ? ? ? </plugin> ? ? ? </plugins> ? </build>
maven配置阿里云鏡像倉庫不生效
問題
在{MAVEN_HOME}/conf/settings.xml中添加鏡像配置:
? <mirrors> ? ? <mirror> ? ? ? ? <id>aliyunmaven</id> ? ? ? ? <mirrorOf>*</mirrorOf> ? ? ? ? <name>阿里云公共倉庫</name> ? ? ? ? <url>https://maven.aliyun.com/repository/public</url> ? ? </mirror> ? </mirrors>
但是項(xiàng)目更新時(shí)仍然會(huì)從http://repo.maven.apache.org/maven2下載依賴。
解決方法
在項(xiàng)目的pom.xml中添加如下配置
? <repositories> ? ? <repository> ? ? ? <id>central</id> ? ? ? <url>https://maven.aliyun.com/repository/public</url> ? ? </repository> ? </repositories> ? <pluginRepositories> ? ? <pluginRepository> ? ? ? <id>central</id> ? ? ? <url>https://maven.aliyun.com/repository/public</url> ? ? </pluginRepository> ? </pluginRepositories>
原因
項(xiàng)目的pom會(huì)繼承自super pom,在super pom中指定了從倉庫的地址:
<repositories> ? ? <repository> ? ? ? <id>central</id> ? ? ? <name>Central Repository</name> ? ? ? <url>http://repo.maven.apache.org/maven2</url> ? ? ? <layout>default</layout> ? ? ? <snapshots> ? ? ? ? <enabled>false</enabled> ? ? ? </snapshots> ? ? </repository> ? </repositories> ? ? <pluginRepositories> ? ? <pluginRepository> ? ? ? <id>central</id> ? ? ? <name>Central Repository</name> ? ? ? <url>http://repo.maven.apache.org/maven2</url> ? ? ? <layout>default</layout> ? ? ? <snapshots> ? ? ? ? <enabled>false</enabled> ? ? ? </snapshots> ? ? ? <releases> ? ? ? ? <updatePolicy>never</updatePolicy> ? ? ? </releases> ? ? </pluginRepository> ? </pluginRepositories>
因此需要在項(xiàng)目中覆蓋這一配置。
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用HttpClient實(shí)現(xiàn)文件的上傳下載方法
下面小編就為大家?guī)硪黄褂肏ttpClient實(shí)現(xiàn)文件的上傳下載方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-12-12
關(guān)于Mybatis-Plus?Update更新策略問題
這篇文章主要介紹了關(guān)于Mybatis-Plus?Update更新策略問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-11-11
詳解Java的內(nèi)置異常以及創(chuàng)建自定義異常子類的方法
這篇文章主要介紹了詳解Java的內(nèi)置異常以及創(chuàng)建自定義異常子類的方法,是Java入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-09-09
SpringBoot中的FailureAnalyzer使用詳解
這篇文章主要介紹了SpringBoot中的FailureAnalyzer使用詳解,Spring Boot的FailureAnalyzer是一個(gè)接口,它用于在Spring Boot應(yīng)用啟動(dòng)失敗時(shí)提供有關(guān)錯(cuò)誤的詳細(xì)信息,這對(duì)于開發(fā)者來說非常有用,因?yàn)樗梢詭椭覀兛焖僮R(shí)別問題并找到解決方案,需要的朋友可以參考下2023-12-12

