Maven - 多镜像节点配置

应用场景

在使用单镜像节点配置时,例如使用阿里云的官方单节点镜像


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

此时,如果出现某些依赖包不存在阿里云的 central 仓和 jcenter 仓中(public 是 central 仓和 jcenter 仓的聚合仓),则会发生依赖处理错误,无法顺利打包

而阿里云其实代理了多个仓库,当某些依赖包不存在于 public 仓时,可以去其他的仓库寻找,找到后成功导入依赖,则可以顺利打包

例如 org.pentaho:pentaho-aggdesigner-algorithm:jar:5.1.5-jhyde,因为该依赖包位于 spring-plugin 仓库中,根本不存在中央仓库中,因此使用 public 仓库是无法下载的,需要配置阿里云的 spring-plugin 仓库镜像

多镜像节点配置

根据阿里云官方代理仓库表

仓库名称 代理源地址 使用地址
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

对应配置 central、jcenter、google、spring 和 spring-plugin

注意,在多镜像节点配置的过程中,不能使用 * 配置,否则会导致其他节点配置无效



    aliyunmaven-central
    central
    central
    https://maven.aliyun.com/repository/public



    aliyunmaven-jcenter
    jcenter
    jcenter
    https://maven.aliyun.com/repository/public



    aliyunmaven-google
    google
    google
    https://maven.aliyun.com/repository/google



    aliyunmaven-spring
    spring
    spring
    https://maven.aliyun.com/repository/spring



    aliyunmaven-spring-plugin
    spring-plugin
    spring-plugin
    https://maven.aliyun.com/repository/spring-plugin

配置完镜像,保存重启 IDE,再次导入 maven 即可完成

你可能感兴趣的:(Maven - 多镜像节点配置)