背景
開(kāi)發(fā)環(huán)境:
- 操作系統(tǒng):mac os x
- IDE:IntelliJ IDEA 2016.3
1.從spring的github頁(yè)面下載源碼,可以選擇下載zip包或者:
git clone https://github.com/spring-projects/spring-framework.git
由于我本機(jī)嘗試git clone發(fā)現(xiàn)速度較慢,選擇了下載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的描述,首先預(yù)編譯spring-oxm秕磷,進(jìn)入源碼目錄,下發(fā)命令:
./gradlew cleanIdea :spring-oxm:compileTestJava
發(fā)現(xiàn)報(bào)錯(cuò),沒(méi)有找到辦法解決(查閱資料引镊,可能是網(wǎng)絡(luò)問(wèn)題)
換一種思路,直接通過(guò)IntelliJ IDEA使用gradle構(gòu)建項(xiàng)目:
1.IntelliJ IDEA篮条,導(dǎo)入項(xiàng)目:
2.選擇spring源碼目錄
3.選擇使用gradle構(gòu)建:
4.選擇gradle的目錄弟头,然后點(diǎn)擊Finish:
5.然后開(kāi)始構(gòu)建,耗時(shí)較長(zhǎng)(實(shí)際耗時(shí)超過(guò)1個(gè)小時(shí))涉茧,構(gòu)建完成后如下:
接下來(lái)就可以安心地閱讀源碼了赴恨,友情提醒下,可以先把Spring技術(shù)內(nèi)幕這本書(shū)快速瀏覽一遍伴栓,這樣你讀源碼的時(shí)候可以有重點(diǎn)伦连,有選擇的去閱讀