刚开始遇到这个问题的时候,我试着搭了梯子来进行下载,但是没有用,于是又查了很多东西,最终得以解决。方法如下:
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
}
}
}
4、此时重新打开idea,稍等片刻,就会发现依赖包均已经下载完毕。
版权声明:本文为weixin_44596487原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。