IntelliJ IDEA Maven/Gradle仓库下载速度慢

发布时间 2023-05-20 12:51:27作者: 006hjy

阿里Maven仓库:https://developer.aliyun.com/mvn/guide

华为Maven仓库:https://www.huaweicloud.com/special/maven-jingxiang.html

腾讯镜像仓库:https://mirrors.tencent.com/

网易镜像仓库:https://mirrors.163.com/

Maven仓库:https://mvnrepository.com/

 

打开C:\Users\用户名\.gradle文件夹,找到文件init.gradle

 

用文本编辑器打开init.gradle

替换成如下内容:

allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public'
        def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/public'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
            allowInsecureProtocol = true
            url ALIYUN_REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}

 

https://plugins.jetbrains.com/