下载spring源码
下载地址:spring-framework v5.2.1.RELEASE
打开 .\spring-framework-5.2.1.RELEASE\gradle\wrapper\gradle-wrapper.properties 文件
完成下载Gradle之后再做如下修改:
#distributionUrl=https://services.gradle.org/distributions/gradle-5.6.3-bin.zip
distributionUrl=file:///D:/gradle-5.6.3/gradle-5.6.3-bin.zip
下载Gradle
在 【D:\gradle-5.6.3\init.d】目录下新建【init.gradle】文件
allprojects {
repositories {
maven { url 'file:///D:/g2repo'}
mavenLocal()
maven { name "Alibaba" ; url "https://maven.aliyun.com/repository/public" }
maven { name "Bstek" ; url "http://nexus.bsdn.org/content/groups/public/" }
mavenCentral()
}
buildscript {
repositories {
maven { name "Alibaba" ; url 'https://maven.aliyun.com/repository/public' }
maven { name "Bstek" ; url 'http://nexus.bsdn.org/content/groups/public/' }
maven { name "M2" ; url 'https://plugins.gradle.org/m2/' }
}
}
}
进入spring-framework工程目录
打开【import-into-idea.md】文件,按照以下步骤操作:
Within your locally cloned spring-framework working directory:
- Precompile
spring-oxm
with./gradlew :spring-oxm:compileTestJava
- Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
- When prompted exclude the
spring-aspects
module (or after the import via File-> Project Structure -> Modules) - Code away
参照上述第2步导入工程到IDE之后做如下配置
补充:需要unload spring-aspect 项目,否则会编译出错!
完成上述三步之后就能编译和测试成功了!