SpringBoot 2.3.0 supports Gradle, it is time to switch from Maven to Gradle-Gradle installation, configuration and mirror source settings

1. Download

note:

  1. Spring Boot plugin 需要Gradle 5 (仅支持5.6.x) 或者 Gradle 6 (6.3或更新版本)
  2. If you are using a version of IDEA is 2018.2.4then you need to use Gradle 5.6.x, otherwise you may encounter problems not Build the (pro-test 2018.2.4version of the IDEA requires to function properly Build 5.6.4)
  3. IDEA users of 2018.2.4 version please use Gradle 5.6.4
  4. Attached here is the Gradle 6.4 download link used in the demonstration of this article

Enter the official website , click Install Gradle
Gradle official website
Find download link
Download the Gradle package

2. Configuration

  • Unzip the downloaded Gradle archive to a certain path, I unzip it here F:\Code\Dependencies\Gradle, the directory structure is as shown in the figure below

Directory structure after decompression

  • Configure environment variables

    My Gradle bin path isF:\Code\Dependencies\Gradle\bin

Environment variable configuration

3. Verification

Open cmd or powershell input

gradle -v

If the following message appears, Gradle configuration is successful
View Gradle version
If the above information is not displayed, please check whether the environment variable configuration is correct

4. Change the mirror source to speed up the download

  • The current directory takes effect

In the project root directory build.gradleto modify / add repositories in the configuration file

repositories {
    maven { url "https://maven.aliyun.com/repository/public" }
    maven { url "https://maven.aliyun.com/repository/spring" }
}
  • Configuration takes effect globally

Find C:\Users\{你的用户名}\.gradle\init.gradlefile

If you cannot find the init.gradle file after installation, please create a new one yourself

Configure gradle mirror source

init.gradleThe content of the file is as follows

allprojects {
    repositories {
        maven { url "https://maven.aliyun.com/repository/public" }
        maven { url "https://maven.aliyun.com/repository/spring" }
        mavenLocal()
        mavenCentral()
    }
}

5. Set Gradle local warehouse location

This setting can be skipped, but the local warehouse location is not set. Gradle will download the jar package to the C drive by default (in the .gradle folder under USER_HOME)

Set environment variables for warehouse location

6. Create Gradle Project

Open IDEA and create a new SpringBoot project.
1
23
45
If the IDEA pop-up window requires Gradle to be configured, follow the settings below
Gradle configuration in IDEA
. The results of the successful configuration are all green ticked!
Gradle run results

7. You're done

Let's feel the charm of Gradle!

Guess you like

Origin blog.csdn.net/JikeStardy/article/details/106843811