编译一次spring源码
下载Spring
github地址:spring-framework
选择分支下载最新的源码
Gradle编译
下载
gradle地址:https://gradle.org/releases/
提示:下载binary-only即只带bin的包,由于
配置环境变量
可自行百度
开始编译
推荐博客:https://blog.csdn.net/bskfnvjtlyzmv867/article/details/81171802
进入 spring-framework
文件夹下,打开cmd,输入 gradlew :spring-oxm:compileTestJava
进行编译
会去下载spring依赖的一些包
IDEA导入源码
等待IDEA构建项目完成即可。ps:等的有点久….
开始的时候
刚开始也没下过源码,完了后按照网上操作:
1.cmd 切到:spring-framework-5.0.4.RELEASE 目录
运行gradlew.bat
2.导入idea
大概构建了一个多小时
然后新建一个gradle项目测试的时候就报各种错
各种报错
1.Error:Kotlin: [Internal Error] java.lang.AbstractMethodError: org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar.registerProjectComponents(Lcom/intellij/mock/MockProject;Lorg/jetbrains/kotlin/config/CompilerConfiguration;)V
解决:左上角-file-settings-plugins,更细Kotlin即可
2.java: 程序包org.springframework.cglib.core不存在:unchecked怎么使用
问题:缺少各种包
解决:spring-framework
文件夹下,打开cmd,输入gradlew :spring-oxm:compileTestJava
,然后重新导入项目。多重试几次就好了
ps(我重试一次就ok了)
编译成功
新建一个gradle项目测试一下
build.gradle
依赖项目spring-context就行
plugins {
id 'java'
}
/*group 'org.springframework'
version ''*/
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile project(':spring-context')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
完美打印出hello spring
๑乛◡乛๑