解读Spring源码之前的准备

本文详细介绍如何使用Gradle和IntelliJ IDEA设置Spring5源码的学习环境。从下载源码到导入IDEA,再到排除可能遇到的问题,一步步引导读者深入理解Spring框架的工作原理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

请忽略以下的文章,现在回过头来才发现学习源码不用如此复杂

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

 

 

转载于:https://www.cnblogs.com/Profound/p/7234618.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值