搭建Spring源码环境

扫码关注公众号:Java 技术驿站

发送:vip
将链接复制到本浏览器,永久解锁本站全部文章

【公众号:Java 技术驿站】 【加作者微信交流技术,拉技术群】

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

本文使用分支4.3.x

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

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

20191102100631\_1.png

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


来源:http://ddrv.cn

赞(0) 打赏
版权归原创作者所有,任何形式的转载请联系博主:daming_90:Java 技术驿站 » 搭建Spring源码环境

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏