Maven配置阿里雲鏡像settings.xml文件


mvaen的環境變量配置
環境配置
右鍵我的電腦-屬性-高級系統設置-環境變量-系統變量-Path
Path—編輯

新建—輸入本機maven的地址—確定—確定—確定

檢查環境變量是否配置成功
Win + R 然后輸入cmd 打開命令行,輸入如下命令
1
mvn -v
1
出現下圖就配置成功啦

3、配置maven 下載倉庫
使用maven時,會自動下載所需要的jar包。方便我們管理我們需要指定下載資源的存放路徑
指定倉庫位置
打開 maven 所在目錄下的settings.xml (我的路徑D:\apache-maven-3.3.9\conf)
1
2
找到下列代碼-------52行左右
<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
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
1
2
3
4
5
6
7
8
9
<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
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
<!-- 加上下列代碼 路徑可自定義(用於存放maven下載的包)-->
<localRepository>D:\apache-maven-3.3.9\repository</localRepository>
1
2
3
4
5
6
7
8
9
10
4、配置maven 國內鏡像
默認鏡像下載速度很慢,本帖使用阿里雲提供鏡像
同理---打開 maven 所在目錄下的settings.xml (我的路徑D:\apache-maven-3.3.9\conf)
1
找到下列代碼-------147行左右
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<!-- 加上下列代碼 配置鏡像-->
<mirror>
<id>alimaven</id>
<mirrorOf>*</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
5、配置完成
可以愉快的使用maven啦~~
————————————————
版權聲明:本文為CSDN博主「小飛飛y」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/acsiont/article/details/99762592


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM