intellij idea15搭建spring源码阅读环境

intellij idea15搭建spring源码阅读环境

标签: 源码学习

环境准备

(1)下载intellij idea15
官网下载连接:https://www.jetbrains.com/idea/download/
建议下载Ultimate版本,这样对web开发的支持组件比较多,开发较为方便,有经济能力的建议支持正版,没有的话你懂的。

(2)下载jdk8,配置java环境

(3)clone spring源码
spring源码github地址:https://github.com/spring-projects/spring-framework
下载源码后别着急用idea打开,首先阅读源码中的import-into-idea.md文件,文件内容如下,按着一步步操作即可

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

(4)用idea打开spring源码 随便写了一个test,运行结果如下图所示:运行结果

问题:
(1)源码按照上面导入后,gradle build 也成功了,但是自己写测试代码可能还会报一些包找不到的问题,如图

这是由于idea打开spring源码后依赖没有正确配置,添加依赖即可解决
这里写图片描述
(2)如果依赖都正确配置了,但是程序还是无法运行,那可能是依赖顺序问题,详细可查阅这个博客
http://www.wurenny.com/2015/04/17/186

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值