第一步、准备gradle环境
1、去官网下载gradle https://gradle.org/releases/
2、将其解压缩,创建repository 文件夹 和init.d 文件夹
创建init.gradle 文件 输入文本信息,主要是配置阿里云镜像仓库地址,和maven的类似
gradle.projectsLoaded {
rootProject.allprojects {
buildscript {
repositories {
def JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter'
def GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
def NEXUS_URL = 'http://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 GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
def NEXUS_URL = 'http://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
}
}
}
}
3、为了方便,设置环境变量GRADLE_HOME 和GRADLE_USER_HOME(看后面的截图就明白会被idea使用)
GRADLE_HOME
gradle路径,例如:
D:\Program Files\gradle-6.8.3
第二步、下载spring源码
github下载源码比较慢,我们通过码云的方式将其下载下来。当然也可以直接从github的官网直接拉取下拉。
spring源码官网:https://github.com/spring-projects/spring-framework
以下是同步到码云的操作
确认后就可以同步完成了 由于从码云上拉取代码需要ssh校验
如果之前有弄过ssh-keygen -t rsa 也就是在个人文件夹下有一个.ssh 文件夹里面有一个公钥 如下,讲id_rsa.pub已文本打开,复制里面的内容。
然后我们就可以通过IDEA的get from version control 复制ssh的连接,然后粘贴到idea中,与github上的git操作一致
刷新以下gradle依赖,首次刷新会非常慢,如果遇到了错误提示,则根据错误提示进行处理。完成后就会像我这样。 完成上面操作后spring的源码环境就算完成了。
|