mac配置spring源码阅读环境
2017-02-09 本文已影响0人
测试你个头
背景
开发环境:
- 操作系统: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包
![](https://img.haomeiwen.com/i4383604/081f9d0a38772a69.png)
2.解压缩zip包
![](https://img.haomeiwen.com/i4383604/fff6e256b0c77c7b.png)
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
发现报错,没有找到办法解决(查阅资料,可能是网络问题)
![](https://img.haomeiwen.com/i4383604/a9223dd3e6fa1757.png)
换一种思路,直接通过IntelliJ IDEA使用gradle构建项目:
1.IntelliJ IDEA,导入项目:
![](https://img.haomeiwen.com/i4383604/089ddb2ad31342da.png)
2.选择spring源码目录
![](https://img.haomeiwen.com/i4383604/9081b8c4e308240a.png)
3.选择使用gradle构建:
![](https://img.haomeiwen.com/i4383604/80869741beea6888.png)
4.选择gradle的目录,然后点击Finish:
![](https://img.haomeiwen.com/i4383604/4be5ca307a8fcacb.png)
5.然后开始构建,耗时较长(实际耗时超过1个小时),构建完成后如下:
![](https://img.haomeiwen.com/i4383604/82f585741ae8a9d8.png)
接下来就可以安心地阅读源码了,友情提醒下,可以先把Spring技术内幕这本书快速浏览一遍,这样你读源码的时候可以有重点,有选择的去阅读