开始
要开始使用这个插件,需要将其应用到你的项目中。
该插件发布到 Gradle 的插件门户,并可通过插件块:
-
Groovy
-
Kotlin
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id 'org.springframework.boot' version '4.0.0'
}
plugins {
id("org.springframework.boot") version "4.0.0"
}
单独应用时,插件对项目几乎不做修改。相反,插件检测到是否应用了其他插件并做出相应反应。例如,当Java插件被应用,构建可执行 jar 的任务会自动配置。典型的 Spring Boot 项目会应用槽的,Java或org.jetbrains.kotlin.jvm插件作为最低限度,同时也使用io.spring.dependency-management插件或 Gradle 原生 BOM 支持的依赖管理。 例如:
-
Groovy
-
Kotlin
plugins {
id 'java'
id 'org.springframework.boot' version '4.0.0'
}
apply plugin: 'io.spring.dependency-management'
plugins {
java
id("org.springframework.boot") version "4.0.0"
}
apply(plugin = "io.spring.dependency-management")
想了解更多关于 Spring Boot 插件在应用其他插件时的表现,请参阅“响应其他插件”部分。