springBoot源码之--环境搭建-gradle搭建

gradle搭建笔记

推荐使用 idea版本:2021.2或以上  gradle 版本6.9.1
版本2.5.x
0、本源码下载地址链接:https://github.com/spring-projects/spring-boot/tree/2.5.x
使用Git下载  git clone -b 2.5.x https://github.com/spring-projects/spring-boot.git
1、使用idea打开 然后修改build.gradle文件
因为 Gradle 支持使用 Maven 依赖,所以我们可以使用阿里云的 Maven 镜像 https://maven.aliyun.com/nexus/content/groups/public/**。修改 build.gradle 文件,


2.修改下载源 
gradle\wrapper中的配置文件  --- gradle-wrapper.properties
//这里Gradle换成你自己存放gradle的路径以及gradle的压缩包名
//这里需要注意的是gradle版本问题,尽量高一点儿,就是用了gradle-4.9的版本,导致报错gradle-api plugins问题,还缺包啥的,换了包之后就没问题了
distributionUrl=file:///D:/java/gradle/gradle-6.2.2-bin.zip

 


3.buildSrc下的build.gradle

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" }
mavenCentral()
gradlePluginPortal()
maven { url "https://repo.spring.io/release" }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
.......

 注释掉测试,否则抛错

4、修改 
settings.gradle
pluginManagement {
   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" }
      mavenCentral()
      gradlePluginPortal()
   }
   resolutionStrategy {
      eachPlugin {
         if (requested.id.id == "io.spring.javaformat") {
            useModule "io.spring.javaformat:spring-javaformat-gradle-plugin:${requested.version}"
         }
      }
   }
}


5、gradle.properties //===也可以不改
新增如下配置,解决heap堆内存空间不够问题
gradlePropertiesProp=gradlePropertiesValue
sysProp=shouldBeOverWrittenBySysProp
systemProp.system=systemValue
org.gradle.caching=false
org.gradle.jvmargs=-Xms2048m -Xmx4096m
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.configureondemand=true
6、根目录下的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" }
}
}

allprojects {
group "org.springframework.boot"

   repositories {
      maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
      maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
      mavenCentral()
      if (!version.endsWith('RELEASE')) {
         maven { url "https://repo.spring.io/milestone" }
      }
      if (version.endsWith('BUILD-SNAPSHOT')) {
         maven { url "https://repo.spring.io/snapshot" }
      }
   }

   configurations.all {
      resolutionStrategy.cacheChangingModulesFor 60, "minutes"
   }
}
8、seetings.gradle

pluginManagement {
        repositories {
                maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
                maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
        mavenCentral()
        gradlePluginPortal()
        maven {
                url 'https://repo.spring.io/plugins-release'
        }
        if (version.endsWith('BUILD-SNAPSHOT')) {
            maven { url "https://repo.spring.io/snapshot" }
        }
}
resolutionStrategy {
    eachPlugin {
        if (requested.id.id == "org.jetbrains.kotlin.jvm") {
            useVersion "${kotlinVersion}"
        }
        if (requested.id.id == "org.jetbrains.kotlin.plugin.spring") {
            useVersion "${kotlinVersion}"
        }
    }
}
}

注意:idea的关于gradle的配置如下

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

敬业小码哥

你的鼓励是我的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值