Spring boot 使用gradle BOM和spring boot(多模块应用)的更好方法是什么
我使用Spring boot 使用gradle BOM和spring boot(多模块应用)的更好方法是什么,spring-boot,gradle,gradle-plugin,spring-boot-gradle-plugin,maven-bom,Spring Boot,Gradle,Gradle Plugin,Spring Boot Gradle Plugin,Maven Bom,我使用Gradle构建spring-boot应用程序。我想要什么 我有一个多模块应用程序,其中一些模块是springboot应用程序。我想在父项目的Gradle文件中获取BOMspring依赖项,并使用所有没有版本的库 现在我有了下一个配置: buildscript { repositories { mavenCentral() } dependencies { classpath("org.spr
Gradle
构建spring-boot
应用程序。我想要什么
我有一个多模块应用程序,其中一些模块是springboot
应用程序。我想在父项目的Gradle文件中获取BOM
spring依赖项,并使用所有没有版本的库
现在我有了下一个配置:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
我在每个模块中复制这个代码。我读了《格雷德尔》,看到了这一点:
插件本身不会自动应用Spring依赖项
管理插件。相反,它会对弹簧产生反应
正在应用和配置的依赖项管理插件
spring boot dependencies BOM(物料清单)。我们将深入了解更多
本文后面将详细介绍BOM表支持。)
下面有一个例子:
plugins {
id 'java'
id 'com.gradle.build-scan' version '1.16'
id 'org.springframework.boot' version '2.0.5.RELEASE'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE'
...
我很困惑。什么变体更好?我试图像以下文档那样更改代码,但出现了一个错误:
> Could not resolve all files for configuration ':my-server:compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter-data-jpa:.
Required by:
project :my-server
> Could not find org.springframework.boot:spring-boot-starter-cache:.
Required by:
project :my-server
> Could not find org.springframework.boot:spring-boot-configuration-processor:.
Required by:
project :my-server
> Could not find org.hibernate:hibernate-jpamodelgen:.
Required by:
project :my-server
> Could not find org.projectlombok:lombok:.
Required by:
project :my-server
> Could not find org.springframework.kafka:spring-kafka:.
Required by:
project :my-server
您仍然需要为依赖项定义
存储库
。将下面的行添加到build.gradle
repositories {
mavenCentral()
}
您仍然需要为依赖项定义
存储库
。将下面的行添加到build.gradle
repositories {
mavenCentral()
}