解讀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
View Code

大致意思就是:

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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM