下载源码
地址https://github.com/spring-projects/spring-framework/tree/v5.2.9.RELEASE
查看gradle对应版本
spring-framework-5.2.9.RELEASE/gradle/wrapper/gradle-wrapper.properties
# 其他配置暂未了解具体用处,一切默认值
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
#默认通过网络从https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip地址进行下载,可以下载后放到spring-framework-5.2.9.RELEASE/gradle/wrapper/下,避免因为网络导致下载失败
#distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionUrl=gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
进行gradle电脑本地化配置
# 源码解压后目录 spring-framework-5.2.9.RELEASE 中执行命令
sh gradlew
不知道为什么出现下面的问题,百度得到的答案是注释掉依赖
FAILURE: Build failed with an exception.
* Where:
Build file '/***/spring-framework-5.2.9.RELEASE/build.gradle' line: 3
* What went wrong:
Plugin [id: 'io.spring.gradle-enterprise-conventions', version: '0.0.2'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'io.spring.gradle-enterprise-conventions:io.spring.gradle-enterprise-conventions.gradle.plugin:0.0.2')
Searched in the following repositories:
Gradle Central Plugin Repository
maven(https://repo.spring.io/plugins-release)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
执行成功
> Task :help
Welcome to Gradle 5.6.4.
To run a build, run gradlew <task> ...
To see a list of available tasks, run gradlew tasks
To see a list of command-line options, run gradlew --help
To see more detail about a task, run gradlew help --task <task>
For troubleshooting, visit https://help.gradle.org
BUILD SUCCESSFUL in 4s
1 actionable task: 1 executed
导入idea步骤
根据spring-framework-5.2.9.RELEASE/import-into-idea.md中目录操作
-
使用 ./gradlew :spring-oxm:compileTestJava 命令编译 spring-oxm
spring-framework-5.2.9.RELEASE % ./gradlew :spring-oxm:compileTestJava > Task :spring-oxm:genJaxb [ant:javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [ant:javac] 警告: [options] 未与 -source 8 一起设置引导类路径 [ant:javac] 1 个警告 BUILD SUCCESSFUL in 6s 40 actionable tasks: 22 executed, 18 from cache
-
将项目到入idea中
File -> New -> Project from Existing sources
选中spring-framework-5.2.9.RELEASE/build.gradle
idea配置gradle信息
Use Gradle from :Specified location 使用本地的gradle配置
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wtM6h7EQ-1688043530376)(spring-framework-5.2.9.RELEASE%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91.assets/image-20230629195345193.png)]
错误解决
Kotlin: warnings found and -Weeror specified
使用如下强制措施,关闭Kotlin的-Weeror校验,删除-Weeror。
配置国内Maven镜像
// /***/spring-framework-5.2.9.RELEASE/build.gradle
repositories {
mavenCentral()
maven { url "https://repo.spring.io/libs-spring-framework-build" }
maven { url "https://repo.spring.io/snapshot" } // Reactor
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/'} //阿里云
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
}