java - 当我们已经使用 id "io.spring.dependency-management"插件时,我们还需要 "org.springframework.boot"gradle 插件吗

标签 java spring-boot gradle

当 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 插件来提供 bootJarbootRun 等任务。这是一个应该可以工作的最小 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/

相关文章:

Java 类路径找不到 MySQL 驱动程序

java - 如何将主键的 Id 填充到外键

java - 如何在我的 Spring Boot 代码中处理亚马逊 s3 存储桶的 404 错误

android - 在 active-android 中发现意外的元数据类型

java - 检查字符串是否是回文

java - Intellij 生成静态最终字段

java - Spring Boot 日志记录中的 ClassCastException

java - Spring Boot Jersey 静态内容,资源位于 "/"

Grails Inline Plugin 导致 grails 2.3.8 中的打包错误

java - 关于android文件管理、Android环境概念和android库插件