如何將maven源改為國內(nèi)阿里云鏡像
由于眾所周知的原因,maven的庫在中國大陸非常慢。我在百度上搜到的大部分文章都是直接在~/.m2/settings.xml 加入以下內(nèi)容
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public </url>
</mirror>
</mirrors>其實(shí)這樣設(shè)置,我發(fā)現(xiàn)其實(shí)鏡像并沒有改變,還是maven的中央庫。在maven庫的官網(wǎng)上http://maven.apache.org/settings.html,是建議我們這樣設(shè)置的。但是我發(fā)現(xiàn),有時(shí)候,阿里云maven源有的包下載不了。所以我建議設(shè)置如果阿里云下載不了,就去下載中央庫。所以我的設(shè)置如下:
<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/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共倉庫</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>central repo</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>apache snapshots</mirrorOf>
<name>阿里云阿帕奇?zhèn)}庫</name>
<url>https://maven.aliyun.com/repository/apache-snapshots</url>
</mirror>
</mirrors>
<proxies/>
<activeProfiles/>
<profiles>
<profile>
<repositories>
<repository>
<id>aliyunmaven</id>
<name>aliyunmaven</name>
<url>https://maven.aliyun.com/repository/public</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>MavenCentral</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>aliyunmavenApache</id>
<url>https://maven.aliyun.com/repository/apache-snapshots</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>還有一個(gè)令人困惑的是標(biāo)簽mirrorOf,根據(jù)maven官網(wǎng)解釋 specify the mirror of setting that is the ID of the repository you are using a mirror of。這句話令人困惑,我猜的意思就是https://maven.aliyun.com/repository/central下的哪個(gè)倉庫,如果是*號,就包含了所有倉庫。比如看下圖,

總結(jié)
到此這篇關(guān)于如何將maven源改為國內(nèi)阿里云鏡像的文章就介紹到這了,更多相關(guān)maven源改為國內(nèi)阿里云鏡像內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
mybatis-plus之如何根據(jù)數(shù)據(jù)庫主鍵定義字段類型
這篇文章主要介紹了mybatis-plus之如何根據(jù)數(shù)據(jù)庫主鍵定義字段類型問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-07-07
微信js-sdk+JAVA實(shí)現(xiàn)“分享到朋友圈”和“發(fā)送給朋友”功能詳解
本文分享了微信js-sdk+JAVA實(shí)現(xiàn)“分享到朋友圈”和“發(fā)送給朋友”功能介紹,大家可以參考一下2018-03-03
玩轉(zhuǎn)SpringBoot中的那些連接池(小結(jié))
這篇文章主要介紹了玩轉(zhuǎn)SpringBoot中的那些連接池(小結(jié)),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12
Springboot @Transactional使用時(shí)需注意的幾個(gè)問題記錄
本文詳細(xì)介紹了Spring Boot中使用`@Transactional`注解進(jìn)行事務(wù)管理的多個(gè)方面,包括事務(wù)的隔離級別(如REPEATABLE_READ)和傳播行為(如REQUIRES_NEW),并指出了在同一個(gè)類中調(diào)用事務(wù)方法時(shí)可能遇到的問題以及解決方案,感興趣的朋友跟隨小編一起看看吧2025-01-01

