Maven之阿里云镜像仓库配置
阿里云仓库地址:
https://maven.aliyun.com/mvn/guide
进入详细看配置
start.spring.io 直接用 https://start.aliyun.com 替代
central仓和jcenter仓的聚合仓:
https://maven.aliyun.com/repository/public
spring:
https://maven.aliyun.com/repository/spring
spring-plugin:
https://maven.aliyun.com/repository/spring-plugin
public:
https://maven.aliyun.com/repository/public
1. 全局配置
添加阿里云的镜像到maven的setting.xml配置中,这样就不需要每次在pom中,添加镜像仓库的配置,在mirrors节点下面添加子节点:
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> <mirror> <id>ui</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://uk.maven.org/maven2/</url> </mirror>
注:< mirrorOf>可以设置为哪个中央仓库做镜像,为名为“central”的中央仓库做镜像,写作< mirrorOf>central< /mirrorOf>;为所有中央仓库做镜像,写作< mirrorOf>< /mirrorOf>。Maven默认中央仓库的id 为 central。id是唯一的。
重要:除非你有把握,否则不建议使用< mirrorOf>< /mirrorOf>的方式。
2. 单项目配置
单项目配置时,需要修改pom.xml文件。pom.xml文件中,没有mirror元素。在pom.xml文件中,通过覆盖默认的中央仓库的配置,实现中央仓库地址的变更。
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public/</url>
<layout>default</layout>
<!-- 是否开启发布版构件下载 -->
<releases>
<enabled>true</enabled>
</releases>
<!-- 是否开启快照版构件下载 -->
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
注:Maven默认中央仓库的id 为 central。id是唯一的。因此使用< id>central< /id>覆盖了默认的中央仓库。
浙公网安备 33010602011771号