一 下载源码
方式1 码云下载
码云是国内的仓库,极速下载是github上面的知名项目镜像,可以快速下载,找到内容后,点击main切换分支,找到自己想看的分支
方式二:github下载
不管是什么方式下载,建议下release版本,避免去踩一些不必要的坑,解决坑是一个体力活很费时费力,本次我下载的是2.3.4版本
二 下载gradle
下载下来zip就可以了
三 修改配置文件编译
修改配置文件主要是修改镜像源和一些踩到的编译坑:
1 gradle\wrapper中的配置文件
将文件内容 修改成自己的目录,就是上面下载的zip gradle目录就可以了
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=file:///D:/java/gradle-6.6.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 buildSrc下的build.gradle
`plugins {
id "java-gradle-plugin"
//可能是原有的编译环境,注释掉,否则报错
//id "io.spring.javaformat" version "${javaFormatVersion}"
id "checkstyle"
}
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
.......`
3 buildSrc下的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}"
}
}
}
}`
4 buildSrc下的gradle.properties
`javaFormatVersion=0.0.22
新增如下配置,解决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`
5 根目录下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"
}
}`
6 根目录下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}" } } } }