欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

如何在Maven中设置阿里云镜像的settings.xml配置文件

最编程 2024-07-22 12:10:01
...
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>