我使用的是idea来学习spring 的源码
根据import-into-idea.md
_Within your locally cloned spring-framework working directory:_
1. Precompile `spring-oxm` with `./gradlew :spring-oxm:compileTestJava`
2. Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
3. When prompted exclude the `spring-aspects` module (or after the import via File-> Project Structure -> Modules)
4. Code away
执行下面的代码,添加了指令,执行的过程更加清晰一些。
.\gradlew.bat --warning-mode all --info --no-build-cache --stacktrace clean :spring-oxm:compileTestJava
修改的位置
- 使用本地的gradle
# distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip
distributionUrl=file\:///D:/java/gradle-6.1-bin.zip
- kotlin 使用的是1.4版本的 idea【setting->plugs->kotlin】需要做到统一
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = ["-Xjsr305=strict"]
apiVersion = "1.4" //之前是1.1
languageVersion = "1.4" //之前是1.1
}
}
- 添加阿里云的仓库
repositories {
maven { url "https://maven.aliyun.com/repository/public" }
maven { url "https://repo.spring.io/libs-release" }
maven { url "https://repo.springsource.org/plugins-release" }
}
- spring beans
循环依赖的处理,修改spring-beans下的spring-beans.gradle,把之前的4行注释掉,添加下面的代码
// def deps = compileGroovy.taskDependencies.immutableValues + compileGroovy.taskDependencies.mutableValues
// compileGroovy.dependsOn = deps - "compileJava"
// compileKotlin.dependsOn(compileGroovy)
// compileKotlin.classpath += files(compileGroovy.destinationDir)
tasks.named('compileGroovy') {
// Groovy only needs the declared dependencies (and not the result of Java compilation)
classpath = sourceSets.main.compileClasspath
}
tasks.named('compileKotlin') {
// Kotlin also depends on the result of Groovy compilation
classpath += files(sourceSets.main.groovy.classesDirectory)
最后祝大家好运!!在学习的过程中遇到好的,还有解决的问题,还是会再贴出来,大家一些学习!!