此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring Boot 3.5.5spring-doc.cadn.net.cn

开始

要开始使用该插件,需要将其应用于您的项目。spring-doc.cadn.net.cn

该插件发布到 Spring 快照存储库。 可以将 Gradle 配置为使用快照存储库,然后可以使用plugins块。 如需将 Gradle 配置为使用快照代码库,请将以下内容添加到settings.gradle(Groovy) 或settings.gradle.kts(Kotlin):spring-doc.cadn.net.cn

/*
 * 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.
 */

pluginManagement {
	repositories {
		maven {
			url = 'https://repo.spring.io/milestone'
		}
		maven {
			url = 'https://repo.spring.io/snapshot'
		}
		gradlePluginPortal()
	}
}
pluginManagement {
	repositories {
		maven { url = uri("https://repo.spring.io/milestone") }
		maven { url = uri("https://repo.spring.io/snapshot") }
		gradlePluginPortal()
	}
}

然后可以使用plugins块:spring-doc.cadn.net.cn

/*
 * 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 '3.5.6-SNAPSHOT'
}
plugins {
	id("org.springframework.boot") version "3.5.6-SNAPSHOT"
}

单独应用时,该插件对项目几乎没有任何更改。 相反,该插件会检测何时应用了某些其他插件并做出相应的反应。 例如,当java插件,自动配置构建可执行 jar 的任务。 典型的 Spring Boot 项目将应用groovy,javaorg.jetbrains.kotlin.jvm插件作为最低限度,并使用io.spring.dependency-management插件或 Gradle 的原生 bom 支持依赖项管理。 例如:spring-doc.cadn.net.cn

plugins {
	id 'java'
	id 'org.springframework.boot' version '3.5.6-SNAPSHOT'
}

apply plugin: 'io.spring.dependency-management'
plugins {
	java
	id("org.springframework.boot") version "3.5.6-SNAPSHOT"
}

apply(plugin = "io.spring.dependency-management")

要了解有关应用其他插件时 Spring Boot 插件的行为方式的更多信息,请参阅有关对其他插件做出反应的部分。spring-doc.cadn.net.cn