首页 > 编程语言 > 详细

SpringBoot源码学习(零) 搭建Springboot源码调试环境

时间:2021-01-16 21:59:29      阅读:122      评论:0      收藏:0      [点我收藏+]

准备环境

若是想将git源码修改记录上传到github,需要将springboot源码fork到本人gitbub。此文是直接下载源码到本地的。

  1. git
  2. jdk1.8+
  3. gradle的压缩包
  4. maven,需配置阿里云仓库
  5. idea 2020.2.1

下载源码

源码地址

https://github.com/spring-projects/spring-boot

克隆源码

git clone -b 2.2.x https://github.com/spring-projects/spring-boot.git

开始构建

打开idea,【File】-->【Open...】,打开刚才拉取的Springboot源码。

技术分享图片

检查环境

选择【File】->【project Structure…】

  1. 检查Project技术分享图片
  2. 检查Model技术分享图片
  3. 检查SDKs技术分享图片

修改gradle相关配置

修改spring-boot-project\spring-boot-tools\spring-boot-gradle-plugin\gradle\wrapper\gradle-wrapper.properties文件distributionUrl属性。

distributionUrl=file:///D:/gradle-6.7.1/gradle-6.7.1-bin.zip

修改spring-boot-project\spring-boot-tools\spring-boot-gradle-plugin\build.gradle文件。

buildscript {
   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/plugins-release" }
      mavenLocal()
      mavenCentral()
   }
   dependencies {
      classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15")
   }
}

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/plugins-release" }
   mavenLocal()
   mavenCentral()
}

源码编译

取消编译源码时测试及清理

找到Spring Boot Build(root)

技术分享图片

开始编译源码

技术分享图片

此时会抛出异常Run spring-javaformat:apply to fix.

解决方案: 控制台执行mvn命令

mvn spring-javaformat:apply

安装到本地仓库

技术分享图片

给源码添加注释之后,记得重新install(按需install)下,要么debbug调试时会出现与源码行数对应不上的情况。

效果图

技术分享图片

SpringBoot源码学习(零) 搭建Springboot源码调试环境

原文:https://www.cnblogs.com/chinda/p/14287146.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!