修改个别项目
在项目的build.gradle文件中,修改repositories配置
由:
资料档案库{
mavenCentral ()
maven { URL ' https://repo.spring.io/snapshot ' }
maven { URL ' https://repo.spring.io/milestone ' }
}
更改:
资料档案库{
maven { URL ' http://maven.a liyun.com/nexus/content/groups/public/' }
}
或:
资料档案库{
maven { URL ' http://maven.oschina.net/content/groups/public/' }
}
这样,就可以从国内镜像下载依存关系,从而大大提高速度
注意:
build.gradle文件中有两处repositories,都需要修改
AlibabaCloud (阿里巴巴云)的速度比较快,更稳定
更改所有项目
如果要一次更改所有仓库的地址,可以在C:Usershellowood.gradle和“. gradle”文件夹下添加并配置init.gradle文件
init.gradle
所有项目{
资料档案库{
def repository _ URL=' http://maven.a liyun.com/nexus/content/groups/public/'
全部{ artifact repository repo -
存储库(if ) {
def url=repo.url.toString (
URL.starts with (https://repo1. maven.org/maven2(|URL.starts with ) ) https://jcenter.bintray.com/' )
移除修复
}
}
}
7 {
URL资料档案库_ URL
}
}
}
这将允许您在编译项目时从蚂蚁仓库下载依赖项
init.build脚本可以查看https://docs.grad le.org/current/user guide/init _ scripts.html