git地址
首先访问spring的git地址https://github.com/spring-projects/spring-framework
点击Fork将spring的源码fork到自己的github中去,这样做目的是可以通过git clone下载代码,构建源码的时候不会报错 (git 128error)。
下载源码
git clone 你自己fork的源码地址,下载成功后,点击Build from Source 查询构建官网说明
编译最新的spring源码需要jdk17, 执行gradlew build 开始编译项目 ,国内替换gradle为阿里云镜像,也可以科学上网等待构建结果。
idea导入
源码构建完成,打开spring源码,grandel开始构建项目,等待构建完成将spring-aspects移除模块,完成spring源码编译。参考官网描述
测试
自定义一个grandel的模块,将spring-context引入到自定义项目中,
创建config类,在创建一个启动类,使用AnnotationConfigApplicationContext configApplicationContext = new AnnotationConfigApplicationContext();进行测试。