gradle 无需提前下载,项目创建之后,会根据gradle-wrapper.properties 自动下在对应配置的 gradle
一、基本配置
1、gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2、gradle.build 配置
buildscript {
// 自定义脚本资源
repositories {
// 脚本仓库
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
// 这个插件包含了 org.springframework.boot 和 io.spring.dependency-management
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.6.6"
}
}
plugins {
id 'java'
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
group 'com.supkingx'
version '1.0-SNAPSHOT'
repositories {
mavenLocal()
maven { url 'https://maven.aliyun.com/repository/public/' }
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
}
test {
useJUnitPlatform()
}
二、代码
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
@RestController
@RequestMapping("/testController")
public class TestController {
@GetMapping("test")
public String test(String param) {
return param + " ok!";
}
}