我编写了一个 Gradle 插件,其中包含一堆常见的设置配置,因此我们所有的项目只需要应用该插件和一组依赖项。它使用 Spring Dependency Management Plugin 为 Spring 设置 BOM 导入,如下面的代码片段所示:
trait ConfigureDependencyManagement {
void configureDependencyManagement(final Project project) {
assert project != null
project.apply(plugin: "io.spring.dependency-management")
final DependencyManagementExtension dependencyManagementExtension = project.extensions.findByType(DependencyManagementExtension)
dependencyManagementExtension.imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:2.1.0.RELEASE"
}
}
}
虽然这在 Gradle 5.1 中仍然有效,但我想用 BOM 导入的新依赖机制替换 Spring 依赖管理插件,所以我将上面的内容更新为现在这样:
trait ConfigureDependencyManagement {
void configureDependencyManagement(final Project project) {
assert project != null
project.dependencies.platform("org.springframework.boot:spring-boot-dependencies:2.1.0.RELEASE")
}
}
不幸的是,这种变化意味着这些 BOM 定义的依赖项都没有被导入,并且在构建项目时我会遇到类似的错误?
找不到 org.springframework.boot:spring-boot-starter-web:。要求:项目:
找不到 org.springframework.boot:spring-boot-starter-data-jpa:。要求:项目:
找不到 org.springframework.boot:spring-boot-starter-security:。要求:项目:
我认为 Gradle 5.1 不再需要 Spring Dependency Management Plugin 是否正确,如果是这样,那么我是否遗漏了一些东西来使它工作?