背景
开发环境:
- 操作系统:mac os x
- IDE:IntelliJ IDEA 2016.3
1.从spring的github页面下载源码,可以选择下载zip包或者:
git clone https://github.com/spring-projects/spring-framework.git
由于我本机尝试git clone发现速度较慢,选择了下载zip包

2.解压缩zip包

3.阅读目录下的import-into-idea.md文件:
Steps
Within your locally cloned spring-framework working directory:
- Precompile
spring-oxmwith./gradlew cleanIdea :spring-oxm:compileTestJava - Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
- When prompted exclude the
spring-aspectsmodule (or after the import via File-> Project Structure -> Modules) - Code away
4.按照Steps的描述,首先预编译spring-oxm,进入源码目录,下发命令:
./gradlew cleanIdea :spring-oxm:compileTestJava
发现报错,没有找到办法解决(查阅资料,可能是网络问题)

编译spring-oxm报错
换一种思路,直接通过IntelliJ IDEA使用gradle构建项目:
1.IntelliJ IDEA,导入项目:

2.选择spring源码目录

3.选择使用gradle构建:

4.选择gradle的目录,然后点击Finish:

5.然后开始构建,耗时较长(实际耗时超过1个小时),构建完成后如下:

接下来就可以安心地阅读源码了,友情提醒下,可以先把Spring技术内幕这本书快速浏览一遍,这样你读源码的时候可以有重点,有选择的去阅读