1、spring源码下载Windows11 IDEA 2021.3 JDK 1.8.331 Git 2.36.1
合集包放在最后链接
spring5.0.X源码(JDK 1.8编译)
https://codeload.github.com/spring-projects/spring-framework/zip/refs/tags/v5.0.14.RELEASE
打开 源码gradlewrapper目录找到gradle-wrapper.properties,查看gradle版本,下载对应或更高版本
4.4.1版本:https://downloads.gradle-dn.com/distributions/gradle-4.4.1-bin.zip
官网:https://gradle.org/releases/
源码gradlewrappergradle-wrapper.properties、源码build.gradle、源码settings.gradle
gradle-wrapper.properties
distributionUrl=file:///E:/gradle/gradle-4.4.1-bin.zip
build.gradle
找到repositories后修改
repositories {
maven{ url 'https://maven.aliyun.com/repository/public' }
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
mavenCentral()
maven { url "https://repo.spring.io/libs-spring-framework-build" }
maven { url "https://repo.spring.io/plugins-release" }
}
找到这两段,然后修改apiVersion和languageVersion 为1.4,本来是1.1,运行代码时会报错
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = ["-Xjsr305=strict"]
apiVersion = "1.4"
languageVersion = "1.4"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = ["-Xjsr305=strict"]
apiVersion = "1.4"
languageVersion = "1.4"
}
}
settings.gradle
第一行添加
pluginManagement {
repositories {
maven { url "https://maven.aliyun.com/repository/public" }
gradlePluginPortal()
maven { url 'https://repo.spring.io/plugins-release' }
}
}
6、源码目录打开终端
执行
./gradlew :spring-oxm:compileTestJava
如遇报错下不动的情况:
前面是在环境变量里配置的本地仓库目录,后面是运行上面代码后,自动解压的gradle目录。
在init.d目录下,新建init.gradle
allprojects{
repositories {
def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
all { ArtifactRepository repo ->
def url = repo.url.toString()
if ((repo instanceof MavenArtifactRepository) && (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com'))) {
project.logger.lifecycle 'Repository ${repo.url} replaced by $REPOSITORY_URL .'
remove repo }
}
maven {
url REPOSITORY_URL }
}
}
基本上没问题了,一路通畅下载
7、IDEA导入(File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)导入后自动下载各种依赖,如遇报错下不动的情况:
指定之前添加了init.gradle的目录
更新一下gradle



