Maven - 阿里云公共代理库

整理自Maven官方文档与阿里云官方文档 - 云效Maven公共代理库

使用单个存储库

通过让Maven镜像所有存储库请求,可以强制Maven使用单个存储库。存储库必须包含所有需要的构件,或者能够将请求代理到其他存储库。当使用带有Maven存储库管理器的内部公司存储库来代理外部请求时,此设置非常有用

为了达到这个目的,将 mirrorOf 设为 *

注意:该特性仅在 Maven 2.0.5+ 中可用


  ...
  
    
      internal-repository
      Maven Repository Manager running on repo.mycompany.com
      http://repo.mycompany.com/proxy
      *
    
  
  ...

  1. id, name: 此镜像的唯一标识符,id用于区分镜像元素,并在连接到镜像时从部分中选择相应的凭据
  2. url: 这个镜像的基本URL,构建系统将使用此URL连接到存储库,而不是原始存储库URL
  3. mirrorOf: 此镜像所在的存储库的id。例如,要指向Maven中央存储库的镜像(https://repo.maven.apache.org/maven2/),请将此元素设置为central

阿里云公共代理库

maven.aliyun.com代理了很多公共的maven仓库

使用maven.aliyun.com中的仓库地址作为下载源,速度更快更稳定

代理的仓库列表

仓库名称 代理源地址 使用地址
central https://repo1.maven.org/maven2/ https://maven.aliyun.com/repository/central 或 https://maven.aliyun.com/nexus/content/repositories/central
jcenter http://jcenter.bintray.com/ https://maven.aliyun.com/repository/jcenter 或 https://maven.aliyun.com/nexus/content/repositories/jcenter
public central仓和jcenter仓的聚合仓 https://maven.aliyun.com/repository/public或https://maven.aliyun.com/nexus/content/groups/public
google https://maven.google.com/ https://maven.aliyun.com/repository/google 或 https://maven.aliyun.com/nexus/content/repositories/google
gradle-plugin https://plugins.gradle.org/m2/ https://maven.aliyun.com/repository/gradle-plugin 或 https://maven.aliyun.com/nexus/content/repositories/gradle-plugin
spring http://repo.spring.io/libs-milestone/ https://maven.aliyun.com/repository/spring 或 https://maven.aliyun.com/nexus/content/repositories/spring
spring-plugin http://repo.spring.io/plugins-release/ https://maven.aliyun.com/repository/spring-plugin 或 https://maven.aliyun.com/nexus/content/repositories/spring-plugin
grails-core https://repo.grails.org/grails/core https://maven.aliyun.com/repository/grails-core 或 https://maven.aliyun.com/nexus/content/repositories/grails-core
apache snapshots https://repository.apache.org/snapshots/ https://maven.aliyun.com/repository/apache-snapshots 或 https://maven.aliyun.com/nexus/content/repositories/apache-snapshots

配置指南

maven配置指南

打开maven的配置文件在标签中添加mirror子节点:


    aliyunmaven
    *
    阿里云公共仓库
    https://maven.aliyun.com/repository/public

如果想使用其它代理仓库,可在节点中加入对应的仓库使用地址

以使用spring代理仓为例:


    spring
    https://maven.aliyun.com/repository/spring
    
        true
    
    
        true
    

gradle配置指南

在build.gradle文件中加入以下代码:

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/public/' }
        mavenLocal()
        mavenCentral()
    }
}

如果想使用maven.aliyun.com提供的其它代理仓,以使用spring仓为例,代码如下:

allProjects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/public/' }
        maven { url 'https://maven.aliyun.com/repository/spring/'}
        mavenLocal()
        mavenCentral()
    }
}

你可能感兴趣的:(Maven - 阿里云公共代理库)