Spring Framework源码导入编译

0.环境准备

Before You Start
To build you will need Git and JDK 8 update 262 or later. Update 262 or later is required due to the dependency on Java Flight Recorder (JFR) types. Note, however, that Oracle JDKs do not include the JFR types. Thus, we recommend an AdoptOpenJDK distribution or similar that includes the JFR types. Be sure that your JAVA_HOME environment variable points to the jdk1.8.0 folder extracted from the JDK download.

如果是JDK8的话,要注意小版本是否符合要求

最好选择高点版本的OpenJDK

AdoptOpenJDK:adoptopenjdk.net/

1.下载 Spring Framework 源码

源码下载地址,Github Spring Framework releases:github.com/spring-proj…

最好选择 RELEASE 版本

选好版本后,直接下载 zip 包即可


官方文档,Build from Source:github.com/spring-proj…

官方文档,Import into your IDE:github.com/spring-proj…

2.解压之后编辑 build.gradle 文件

在顶部 buildscript {…} 中添加 aliyun maven 镜像地址

新版本源码 build.gradle 文件中没有这段的话,可以不加

buildscript {
	repositories {
		maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/' }
		maven{ url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
	}
	dependencies {
		classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16'
		classpath 'io.spring.asciidoctor:spring-asciidoctor-extensions:0.1.3.RELEASE'
	}
}
复制代码

configure(allprojects) {…} 中,找到 repositories {…},也添加 aliyun maven 镜像地址

repositories {
    maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/' }
    maven{ url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
    mavenCentral()
    maven { url "https://repo.spring.io/libs-spring-framework-build" }
}
复制代码

3.编译spring-oxm

打开命令行工具,进入到解压后的文件夹内,执行命令 ./gradlew :spring-oxm:compileTestJava

wuxl_@wuxl_deiMac spring-framework-5.2.0.RELEASE % ./gradlew :spring-oxm:compileTestJava
...
...

BUILD SUCCESSFUL in 2m 9s
复制代码

编译大概两三分钟

BUILD SUCCESSFUL 表示编译成功

如果编译出错,自己根据错误去搜索一下解决方法,不同机器配置不同,错误也不一样。

4.将源码导入idea开发工具

编译完后,就可以将源码导入到开发工具中了

import project -> 选择到源码目录 -> 选择gradle

新版idea没有import project选项的,直接选择open,选择到源码目录即可。

导入项目后,编译也要等很长时间…

我编译完成用了16分钟

BUILD SUCCESSFUL in 16m 27s

5.spring-aspects

如果你的spring-aspects项目里代码报错,可以将该项目移除掉

选中spring-aspects项目,右键 Load/Unload Modules,点击 UNLOAD>,OK

然后Build -> Rebuild Project 即可。

这只是万里长征第一步

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享