关于java:spring源码学习下载编译idea版本

5次阅读

共计 1460 个字符,预计需要花费 4 分钟才能阅读完成。

spring 源代码下载

github 上 spring 源代码地址:https://github.com/spring-pro…,间接从该我的项目上下载源代码

git clone https://github.com/spring-projects/spring-framework.git

这个地址下载是十分慢,有可能还会中途失败,这里通知个小技巧,对于 github 上热门的我的项目,咱们都能够在其镜像站中查找并下载:https://hub.fastgit.org

操作也非常简单,将上述命令中的 (github.com 替换为 hub.fastgit.org),命令如下:

git clone https://hub.fastgit.org/spring-projects/spring-framework.git

切换分支

切换到 release 分支,依据须要切换到本人想学习的分支,本文是以 5.2.x 版本为例。

cd spring-framework
git checkout -b 5.2.x origin/5.2.x

环境筹备

jdk8

gradle 工具,下载地址:https://gradle.org/releases/

源代码导入 idea

file -> open -> 找到下载的 spring-framework 目录下的 build.gradle

留神:要对 idea 的工具进行如下设置

本文应用的 grade-6.6.1 版本,导入时,会呈现如下报错:

Caused by: com.gradle.scan.plugin.BuildScanException: 
The build scan plugin is not compatible with Gradle 6.0 and later.
Please use the Gradle Enterprise plugin instead.
    at com.gradle.scan.plugin.BuildScanPlugin.a(SourceFile:99)

从报错中能够看到,是代码中的局部配置不反对 Gradle6.0 以上版本,在这里能够看到如何解决问题:https://docs.gradle.com/enter…

在 settings.gradle 中增加如下代码:

plugins {id "com.gradle.enterprise" version "3.5"}

删除 build.gradle 中删除如下代码:

id 'com.gradle.build-scan' version '3.2'

再次 reload gradle project,又会呈现如下谬误:

Caused by: groovy.lang.MissingPropertyException: 
Could not get unknown property 'variants' for object of type
org.gradle.api.plugins.internal.DefaultAdhocSoftwareComponent.

gradle/spring-moudle.gradle 正文掉如下代码

// Once we upgrade to Gradle 6.x, we will need to delete the following line ...
// components.java.variants.removeAll {it.outgoingConfiguration.name.startsWith("testFixtures") }

再次 reload gradle project,依据网络状况,缓缓期待编译实现,首次编译要半小时的样子。

BUILD SUCCESSFUL
正文完
 0