搭建Spring源码环境

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

本文使用分支4.3.x

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

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

其中有关于导入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做就好了,这不会出错,你需要的是耐心。







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值