idea导入Spring源码胎教级教程
1.首先你要有git 准备好gradle的环境变量文章最后有相关信息
2.然后在你准备好的文件夹中打开git输入
git clone -b 5.2.x git@github.com:spring-projects/spring-framework.git
等待从git远程下载
3.打开源码文件夹
找到280行修改成这样
这是修改后的样子
repositories { mavenCentral() maven { url "https://maven.aliyun.com/nexus/content/groups/public/"} maven { url "https://maven.aliyun.com/nexus/content/repositories/jcenter"} maven { url "https://repo.spring.io/libs-spring-framework-build" } maven { url "https://repo.spring.io/snapshot" } // Reactor maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" } // RSocket } }
然后打开这个
改成这样
repositories { gradlePluginPortal() maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven{ url 'http://repo.springsource.org/plugins-release'} maven{ url 'https://maven.aliyun.com/repository/public'} maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'} }
之后打开idea导入项目
之后就等他下载完成
再改build.gradle
repositories { maven { url "https://maven.aliyun.com/nexus/content/groups/public/"} maven { url "https://maven.aliyun.com/nexus/content/repositories/jcenter"} maven { url "https://repo.spring.io/libs-spring-framework-build" } maven { url "https://repo.spring.io/snapshot" } // Reactor maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" } // RSocket } } configurations.all { resolutionStrategy { force 'xml-apis:xml-apis:1.4.01' cacheChangingModulesFor 0, "seconds" cacheDynamicVersionsFor 0, "seconds" } }
新建工程
改工程里的build.gradle文件
compile(project(":spring-context")) compile(project(":spring-instrument")) compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.6' testCompile group: 'junit', name: 'junit', version: '4.12'
修改配置
新建测试类测试,报错:
CoroutinesUtils找不到该类
Error:(354, 51) java: 找不到符号 符号: 变量 CoroutinesUtils 位置: 类 org.springframework.core.ReactiveAdapterRegistry.CoroutinesRegistrar
解决方法: 点击File -> Project Structure -> Libraries -> + -> Java,然后选择spring-framework/spring-core/kotlin-coroutines/build/libs/kotlin-coroutines-5.2.4.BUILD-SNAPSHOT.jar,在弹出的对话框中选择spring-core.main,在重新build项目即可。
详情:【spring源码系列-0】spring源码下载、编译、debug_蚂蚁要上天的博客-CSDN博客
gradle安装及下载链接:Gradle | Installation
gradle的配置:
环境变量
修改后打开cmd命令窗口输入
gradle -v 有版本号就是成功
谢谢观看!!!