解读Spring源码之前的准备
请忽略以下的文章,现在回过头来才发现学习源码不用如此复杂
1.IDEA 新建一个maven项目,
2.pom 中倒入 spring5 的基本包,然后利用maven 插件down下源码
3.然后就可以开始,源码分析了。
4.需要做笔记的地方自己摘抄下来即可。
---------------------------------
---------------------------------
---------------------------------
1.安装gradle
spring没有通过maven 构建项目,而是gradle,(点击下载)
gradle 的配置参考 Maven 在Mac下的配置,类似
2.下载源码导入idea,
eclipse的导入我就不讲了,毕竟《spring源码深度解析》就是这么一步一步喂给我们的
我直接下载的spring-framework-master.zip,解压,导入idea那就要看这个import-into-idea.md这个文件了
1 The following has been tested against IntelliJ IDEA 2016.2.2 2 3 ## Steps 4 5 _Within your locally cloned spring-framework working directory:_ 6 7 1. Precompile `spring-oxm` with `./gradlew :spring-oxm:compileTestJava` 8 2. Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle) 9 3. When prompted exclude the `spring-aspects` module (or after the import via File-> Project Structure -> Modules) 10 4. Code away 11 12 ## Known issues 13 14 1. `spring-core` and `spring-oxm` should be pre-compiled due to repackaged dependencies. 15 See `*RepackJar` tasks in the build and https://youtrack.jetbrains.com/issue/IDEA-160605). 16 2. `spring-aspects` does not compile due to references to aspect types unknown to 17 IntelliJ IDEA. See http://youtrack.jetbrains.com/issue/IDEA-64446 for details. In the meantime, the 18 'spring-aspects' can be excluded from the project to avoid compilation errors. 19 3. While JUnit tests pass from the command line with Gradle, some may fail when run from 20 IntelliJ IDEA. Resolving this is a work in progress. If attempting to run all JUnit tests from within 21 IntelliJ IDEA, you will likely need to set the following VM options to avoid out of memory errors: 22 -XX:MaxPermSize=2048m -Xmx2048m -XX:MaxHeapSize=2048m 23 4. If you invoke "Rebuild Project" in the IDE, you'll have to generate some test 24 resources of the `spring-oxm` module again (`./gradlew :spring-oxm:compileTestJava`) 25 26 27 ## Tips 28 29 In any case, please do not check in your own generated .iml, .ipr, or .iws files. 30 You'll notice these files are already intentionally in .gitignore. The same policy goes for eclipse metadata. 31 32 ## FAQ 33 34 Q. What about IntelliJ IDEA's own [Gradle support](http://confluence.jetbrains.net/display/IDEADEV/Gradle+integration)? 35 36 A. Keep an eye on http://youtrack.jetbrains.com/issue/IDEA-53476
大致意思就是:
2.1.预编译`spring-core` and `spring-oxm` ,以spring-core为例,切到该目录,输入命令如图:
如果下载太慢不能忍受,记得科学上网
2.2.导入idea中
Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
2.3.移除 `spring-aspects` module ,说是这个模块会编译错误
2.4.然后就开始Code !!
3.最后环境
另外:gradle的基本用法可以了解下 https://gradle.org/guides/
我们的工作环境还是要说下:spring 5.0 , jdk1.8, gradle 4.0, idea 2017.2
我只想安静的学习,捡拾前人的牙慧。默默地强大如此弱小的我...