修改远程仓库地址
为了加速依赖下载速度,可以通过全局、局部两种方式修改依赖下载仓库的地址
全局修改
按照以下步骤修改STS内置的Maven远程仓库为阿里云:
- 打开STS,进入“Window”菜单,选择“Preferences”。
- 在弹出的窗口中,选择“Maven”选项。
- 在“User Settings”中,点击“Open File”按钮,打开settings.xml文件。
-
在settings.xml文件中,找到<mirrors>
标签,添加以下内容:
| <?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<localRepository>C:/app/maven/repository</localRepository>
<mirrors>
<mirror>
<id>aliyun</id>
<name>aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
<mirrorOf>*</mirrorOf>
</mirror>
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
</mirrors>
</settings>
|
-
保存settings.xml文件,关闭窗口。
- 在STS中,右键单击项目,选择“Maven”菜单,选择“Update Project”。
- 等待Maven更新项目依赖,完成后即可使用阿里云的Maven仓库。
以上就是修改STS内置的Maven远程仓库为阿里云的详细步骤。
局部修改
打开工程pom.xml
文件,增加如下节点:
| <repositories>
<repository>
<id>aliyun-repos</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
|