下面两个链接是我设置好的spring源码
https://github.com/13407196713/my_spring.git
https://gitee.com/raboy/my_spring.git
操作部分来源
https://www.bilibili.com/video/BV1ui4y137K3
https://blog.csdn.net/yy_diego/article/details/116381958
https://blog.csdn.net/guyexiangyun/article/details/106527732
https://ld246.com/article/1617104943096
https://blog.csdn.net/duanNFF/article/details/122294747
https://blog.csdn.net/snow_hope/article/details/115419520
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 4 File-> Project Structure -> Modules)
4 Code away
# -------------
1. 在源码根目录下执行命令:./gradlew :spring-oxm:compileTestJava。
2. 按照箭头的顺序,一直定位到源码的 build.gradle 文件打开。
3. 源码里没有 `spring-aspects` module 模块。
4. 使用代码
1 预备操作(加速下载)
idea + jdk + maven + gradle + git 的配置操作,见 https://blog.csdn.net/qq_40893824/article/details/117587740
把spring在github的源码拉到自己的gitee上,这样本地拉取的速度会变快
https://github.com/spring-projects/spring-framework
https://gitee.com/raboy/spring-framework
选择 release 版本,这是稳定版
git 配置见 https://blog.csdn.net/qq_40893824/article/details/117587740
命令:
git clone --branch [tags标签] [git地址]
或
git clone -b [tags标签] [git地址]
例如:
git clone -b 1.4.1 https://github.com/jumpserver/coco.git
git clone -b v5.2.19.RELEASE https://gitee.com/raboy/spring-framework.git
git clone --branch v5.2.19.RELEASE https://gitee.com/raboy/spring-framework.git
https://developer.aliyun.com/mvn/guide
repositories
mavenLocal()
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
# 这个版本指的是 spring 源码的版本,不是 gradle 的,别瞎改。
version=5.2.19.RELEASE
# 注意名字应该是自己下载的 对应的名字 别无脑复制
org.gradle.jvmargs=-Xmx2048M
## 开启 Gradle 缓存
org.gradle.caching=true
## 开启并行编译
org.gradle.parallel=true
## 启用新的孵化模式
org.gradle.configureondemand=true
## 开启守护进程 通过开启守护进程,下一次构建的时候,将会连接这个守护进程进行构建,而不是重新fork一个gradle构建进程
org.gradle.daemon=true
maven { url "https://maven.aliyun.com/repository/public" }
执行第1步
法1:
gradlew :spring-oxm:compileTestJava
法2:
./gradlew :spring-oxm:compileTestJava
法1 法2 的结果图都出现了 Build scan background action failed.
采取下图即可消失
2 通过 idea 打开 build.gradle 文件
![](https://i-blog.csdnimg.cn/blog_migrate/0746c4a7f527206d05ffca49e1aa9d88.png)
停止Sync(同步),先设置一下idea的配置
确保本地gradle版本与其一致
https://services.gradle.org/distributions/
上图 Gradle JVM 不可以是 17
因为会报错 见下图
上图表明 Sync(同步)结束
虽然有爆红,但finished了就啥问题,不碍事
build 成功
下载 AspectJ
https://www.eclipse.org/aspectj/downloads.php
![](https://i-blog.csdnimg.cn/blog_migrate/d798fc4bd99eb323ad5baac030f09658.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ceb1760342fe208063b5eb40025c2a3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/16bf3e934f34ade38d09d46e9ff710a5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/38427622cf9be82ace10684d1653f519.png)
![](https://i-blog.csdnimg.cn/blog_migrate/afb6e22294b1f61c8a1ae67393133b2a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a152055a9ed086571483090eb3b2ac91.png)
注册 AspectJ
D:\download\programming\IntelliJ_IDEA\tools\aspectj\bin;
D:\download\programming\IntelliJ_IDEA\tools\aspectj\bin
win + r + cmd
+ ajc
![](https://i-blog.csdnimg.cn/blog_migrate/1929eddd0d54e941a5d09c73fe188901.png)
aspectj 安装成功
idea 配置 AspectJ