当 spring-boot 插件添加到 Gradle 项目时会发生什么?为什么我们还需要显式包含 spring.dependency-management 插件?
plugins {
id "org.springframework.boot" version "2.1.5.RELEASE"
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
}
最佳答案
自 Gradle 5+ supports BOM文件,您不再需要依赖管理插件。仍然需要 Spring Boot 插件来提供 bootJar
和 bootRun
等任务。这是一个应该可以工作的最小 build.gradle:
buildscript {
ext {
springBootVersion = '2.2.4.RELEASE'
}
}
repositories {
mavenCentral()
}
plugins {
id 'java'
id 'org.springframework.boot' version "${springBootVersion}"
}
dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
关于java - 当我们已经使用 id "io.spring.dependency-management"插件时,我们还需要 "org.springframework.boot"gradle 插件吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57717042/