当前位置:   article > 正文

IDEA中的gradle项目无法下载依赖包或者下载依赖包速度极慢的解决_you can add .gradle init scripts to this directory

you can add .gradle init scripts to this directory. each one is executed at

刚开始遇到这个问题的时候,我试着搭了梯子来进行下载,但是没有用,于是又查了很多东西,最终得以解决。方法如下:
1、找到gradle的安装路径,进去之后会发现有一个init.d的文件夹
2、进入inti.d文件夹,此时仅有一个readme文件,readme文件中写道:

You can add .gradle init scripts to this directory. Each one is executed at the start of the build.

3、看到readme之后解决方法便很明显了,我们只需要在这个文件夹里面新建一个init.gradle文件,其作用是将gradle项目的依赖包下载源更改至国内,具体文件内容如下:

allprojects{
    repositories {
        def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                    remove repo
                }
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

4、此时重新打开idea,稍等片刻,就会发现依赖包均已经下载完毕。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/485035
推荐阅读
相关标签
  

闽ICP备14008679号