搭建Spring源码环境

Spring的源码地址:https://github.com/spring-projects/spring-framework

本文使用分支4.3.x

我曾经不止一次的问自己为什么自己导入的Spring源码这么多错误?捂住这个,冒出那个。把自己搞得精疲力尽,现在我终于知道,我用了错误的方式开启了Spring的大门。

首先,你得下载Spring的源码,打包下载也好,git下载也好。拿到代码后你需要关注下面几个文件

《搭建Spring源码环境》

其中有关于导入idea中的有两种:Eclipse和idea 对应的.bat是为windows用户 .sh文件是linux用户

我是用的IDE是IDEA 15.0.5 我们关注 import-into-idea.md, 它是一个文本文件,直接打开

The following has been tested against Intellij IDEA 13.1

## Steps

_Within your locally cloned spring-framework working directory:_

1. Pre-compile `spring-oxm` with `./gradlew cleanIdea :spring-oxm:compileTestJava`
2. Import into IDEA (File->import project->import from external model->Gradle)
3. Set the Project JDK as appropriate (1.8+)
4. Exclude the `spring-aspects` module (Go to File->Project Structure->Modules)
5. Code away

## Known issues

1. `spring-oxm` should be pre-compiled since it's using repackaged dependencies (see *RepackJar tasks)
2. `spring-aspects` does not compile out of the box due to references to aspect types unknown to IDEA.
See http://youtrack.jetbrains.com/issue/IDEA-64446 for details. In the meantime, the 'spring-aspects'
should be excluded from the overall project to avoid compilation errors.
3. While all JUnit tests pass from the command line with Gradle, many will fail when run from IDEA.
Resolving this is a work in progress. If attempting to run all JUnit tests from within IDEA, you will
likely need to set the following VM options to avoid out of memory errors:
    -XX:MaxPermSize=2048m -Xmx2048m -XX:MaxHeapSize=2048m

## Tips

In any case, please do not check in your own generated .iml, .ipr, or .iws files.
You'll notice these files are already intentionally in .gitignore. The same policy goes for eclipse metadata.

## FAQ

Q. What about IDEA's own [Gradle support](http://confluence.jetbrains.net/display/IDEADEV/Gradle+integration)?

A. Keep an eye on http://youtrack.jetbrains.com/issue/IDEA-53476

重要的说三遍, 看steps段,告诉你要先预编译spring-oxm模块 命令是

./gradlew cleanIdea :spring-oxm:compileTestJava

然后等着就好了。然后你就按上面说的2、3、4、5做就好了,这不会出错,你需要的是耐心。

    原文作者:Spring Boot
    原文地址: https://blog.csdn.net/jiaotuwoaini/article/details/65937185
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞