下载源码
从github上克隆spring-framework项目,并下载到本地。
在build.gradle文件内搜索repositories
添加上阿里云的依赖,将jar包的maven仓库换为阿里云的
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/spring/' }
mavenLocal()
mavenCentral()
}
执行gradle编译
将代码分支切换到5.2.x
,这样对于jdk8版本可以正常执行编译命令,使用master
分支,需要jdk9及以上的jdk版本,否则会报错。
按照import-into-idea.md
的说明执行命令./gradlew :spring-oxm:compileTestJava
.
Downloading https://services.gradle.org/distributions/gradle-5.6.4-bin.zip
.........................................................................................
Welcome to Gradle 5.6.4!
Here are the highlights of this release:
- Incremental Groovy compilation
- Groovy compile avoidance
- Test fixtures for Java projects
- Manage plugin versions via settings script
For more details see https://docs.gradle.org/5.6.4/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :spring-oxm:genJaxb
[ant:javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
BUILD SUCCESSFUL in 3m 20s
40 actionable tasks: 33 executed, 7 from cache
源码导入IDEA
File
=> New
=> Project from existing sources
=> 选择spring-framework
项目目录下的build.gradle
文件,IDEA会自动识别为gradle项目。然后会自动下载依赖包
Coding
项目import完成后,会自动识别出Resources
和Sources
,可以开始coding了。
基础的项目spring-context
依赖spring-beans
,而spring-beans
又依赖spring-core
。阅读代码可以先从spring-core
开始,从核心点一点点往外扩展。
版权声明:本文由 followtry 在 2021年05月07日发表。本文采用CC BY-NC-SA 4.0许可协议,非商业转载请注明出处,不得用于商业目的。
文章题目及链接:《Spring学习--源码环境安装(IDEA)》