背景
開發環境:
- 操作系統: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-oxm
with./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-aspects
module (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技術內幕這本書快速瀏覽一遍,這樣你讀源碼的時候可以有重點,有選擇的去閱讀