Win10 + IDEA2019.3 搭建Spring5.1.x 源码开发环境

时间:2020-03-08
本文章向大家介绍Win10 + IDEA2019.3 搭建Spring5.1.x 源码开发环境,主要包括Win10 + IDEA2019.3 搭建Spring5.1.x 源码开发环境使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

本机环境:

  • Win10 家庭版64位
  • IDEA 2019.3.1
  • Spring 5.1.x
  • Gradle 5.6.4
  • Git 2.20.1

0、编译环境初始化

如上所述的环境都安装好,配置好环境变量:
GRADLE_HOME:

GRADLE_USER_HOME:

然后在CMD查看Gradle的版本如下即表示配置成功:

1、下载Spring源码

我是用git clone 码云的这个镜像下来后,切换到5.1.x 分支。

2、编译-导入源码

Spring-framework的源码目录有个导入IDEA的说明文档:==import-into-idea.md==,内容如下:

_Within your locally cloned spring-framework working directory:_

1. Precompile `spring-oxm` with `./gradlew :spring-oxm:compileTestJava`
2. Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
3. When prompted exclude the `spring-aspects` module (or after the import via File-> Project Structure -> Modules)
4. Code away

1、我们cmd进入这个根目录,然后先编译spring-oxm这个工程,因为其它spring组件会依赖这个。
2、IDEA里面导入这个根目录工程:

选择Spring-framework目录后,选择导入方式为Gradle,然后点击finish:

3、然后点击File -- Project Structure 进去 modules里面排除 Spring-aspect 目录:

5、然后,修改Gradle配置文件,修改版本为 5.6.4:
D:\Study\Spring-framework-5.1.x-gitee\Spring-Framework\gradle\wrapper\gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=file\:/D:/DevEnv/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

==distributionUrl 这个参数的值改为指向你本地的下载的 5.6.4 的zip包路径==

同时修改Cache.properties 里面的Gradle为对应的版本:
D:\Study\Spring-framework-5.1.x-gitee\Spring-Framework.gradle\buildOutputCleanup\cache.properties

然后,在IDEA里面配置Gradle为你自己的版本:

最后,在IDEA里面打开一个终端Terminate,输入命令进行编译即可:

==编译完成后,IDEA会自动建立工程的资源索引,然后展开工程目录,所有的Spring组件包的目录,左侧的文件夹图标都是有右下角那个蓝色标识的,才标识编译完成==

原文地址:https://www.cnblogs.com/xiaocy66/p/12442519.html