http://t.csdn.cn/ERP2L 具体步骤见此链接
下面坑1和坑2都是gradle的加速器配置问题,D:\Dev\gradle-8.1.1\init.d
具体进入你自己装gradle包中的init.d目录下
自己创建框出来的文件
排除下面的两个坑后的最终内容,复制进文件保存即可,截至发稿2023/5/8没有bug
gradle.projectsLoaded {
rootProject.allprojects {
buildscript {
repositories {
// def JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter'
def JCENTER_URL = 'https://maven.aliyun.com/repository/public'
def GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
def NEXUS_URL = 'https://maven.aliyun.com/nexus/content/repositories/jcenter'
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $JCENTER_URL."
println("buildscript ${repo.url} replaced by $JCENTER_URL.")
remove repo
}
else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL."
println("buildscript ${repo.url} replaced by $GOOGLE_URL.")
remove repo
}
else if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
println("buildscript ${repo.url} replaced by $REPOSITORY_URL.")
remove repo
}
}
}
jcenter {
url JCENTER_URL
}
google {
url GOOGLE_URL
}
maven {
url NEXUS_URL
}
}
}
repositories {
// def JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter'
def JCENTER_URL = 'https://maven.aliyun.com/repository/public'
def GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
def NEXUS_URL = 'https://maven.aliyun.com/nexus/content/repositories/jcenter'
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $JCENTER_URL."
println("buildscript ${repo.url} replaced by $JCENTER_URL.")
remove repo
}
else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL."
println("buildscript ${repo.url} replaced by $GOOGLE_URL.")
remove repo
}
else if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
println("buildscript ${repo.url} replaced by $REPOSITORY_URL.")
remove repo
}
}
}
jcenter {
url JCENTER_URL
}
google {
url GOOGLE_URL
}
maven {
url NEXUS_URL
}
}
}
}
坑1:http换为https,注意两处地方http-->https
坑2:上述链接中没提到这一点:注意https://maven.aliyun.com/repository/jcenter换为https://maven.aliyun.com/repository/public 否则一些包就是下载不了,因为国内下不了
坑3:直接搭建测试模块my-spring-source-test时,上述链接里讲的api或者compile统一换为implementation