入门
要开始使用该插件,需要将其应用到你的项目中。
该插件已发布到 Gradle 的插件门户,可以使用 plugins 块来应用
-
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://apache.ac.cn/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 项目至少会应用 groovy、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 插件在应用其他插件时的行为的更多信息,请参阅对其他插件的反应部分。