Basically, there are 2.5 choices here.
Using Gradle's native BOM support
As of Gradle 4.6 it supports BOMs natively. Add these lines in your build files:
settings.gradle:
enableFeaturePreview('IMPROVED_POM_SUPPORT')
Starting from Gradle 5.0 it's not needed.
build.gradle:
dependencies {
implementation("org.springframework.boot:spring-boot-dependencies:2.0.3.RELEASE")
// Now you can import Spring dependencies without particular version:
implementation("org.springframework.boot:spring-boot-starter")
}
Using Spring Boot Gradle plugin
When you apply the io.spring.dependency-management
plugin, Spring Boot’s plugin will automatically import the spring-boot-dependencies
bom from the version of Spring Boot that you are using. This provides a similar dependency management experience to the one that’s enjoyed by Maven users. For example, it allows you to omit version numbers when declaring dependencies that are managed in the bom. To make use of this functionality, simply declare dependencies in the usual way but omit the version number.
build.gradle:
plugins {
id "org.springframework.boot" version "2.0.3.RELEASE"
}
dependencies {
// Now just import what you need:
implementation "org.springframework.boot:spring-boot-starter"
}
Using io.spring.dependency-management
Nice feature is that you can use Spring's dependency plugin even if you're not interested in Spring Boot.
build.gradle:
plugins {
id("io.spring.dependency-management") version "1.0.6.RELEASE"
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.0.6.RELEASE")
mavenBom("com.amazonaws:aws-java-sdk-bom:1.11.409") // Import any bom!
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("com.amazonaws:aws-java-sdk-dynamodb")
}