Spring源码环境搭建
下载gradle
Spring版本用的Gradle(类似于maven但是比maven强大)进行执行和编译,所以需要下载gradle环境
https://gradle.org/releases/
本篇文章使用的6.82版本
https://downloads.gradle-dn.com/distributions/gradle-6.8.2-all.zip
配置环境变量
下载完成后解压,就和配置java环境变量一样,配置系统环境变量
需要配置:GRADLE_HOME、PATH、GRADLE_USER_HOME
- 系统变量(s)中添加:
1
| GRADLE_HOME D:\Program Files (x86)\gradle-6.8.2
|
系统变量(s)中添加:
这里面的变量内容执行你想要存放gradle包的路径,我的是放到了d盘的一个文件夹下
系统变量(s)的path中添加:
配置下载加速
在gradle文件的init.d文件夹下添加init.gradle
文件
内容为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| 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 } } } }
|
整合idea
设置你的geadle仓库地址
下载Spring源码
Spring在github上的仓库地址是:https://github.com/spring-projects/spring-framework
Spring在码云上的仓库地址是:https://gitee.com/mirrors/Spring-Framework
==推荐:自己同步源码==
导入Spring源码
这里是用5.3.4版本:
https://github.com/lvxiaoyi/spring-framework/tree/v5.3.4
注意如果使用别的版本注意不同版本对应的gradle编译版本,不同的spring对应的gradle版本不一样
最新版本需要的gradle编译版本为:7.2,可以在/gradle/wapper/gradle-wrapper.properties中查看