Gradle installation and configuration
1. Download
note:
Spring Boot plugin 需要Gradle 5 (仅支持5.6.x) 或者 Gradle 6 (6.3或更新版本)
- If you are using a version of IDEA is
2018.2.4
then you need to use Gradle 5.6.x, otherwise you may encounter problems not Build the (pro-test2018.2.4
version of the IDEA requires to function properly Build 5.6.4)- IDEA users of 2018.2.4 version please use Gradle 5.6.4
- Attached here is the Gradle 6.4 download link used in the demonstration of this article
Enter the official website , click Install Gradle
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
-
Configure environment variables
My Gradle bin path is
F:\Code\Dependencies\Gradle\bin
3. Verification
Open cmd or powershell input
gradle -v
If the following message appears, Gradle configuration is successful
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.gradle
to 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.gradle
fileIf you cannot find the init.gradle file after installation, please create a new one yourself
init.gradle
The 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)
6. Create Gradle Project
Open IDEA and create a new SpringBoot project.
If the IDEA pop-up window requires Gradle to be configured, follow the settings below
. The results of the successful configuration are all green ticked!
7. You're done
Let's feel the charm of Gradle!