使用gradle BOM和spring-boot(多模块应用程序)哪种方式更好

     2023-02-27     56

关键词:

【中文标题】使用gradle BOM和spring-boot(多模块应用程序)哪种方式更好【英文标题】:What way is better for use gradle BOM and spring-boot(multimodular application) 【发布时间】:2019-08-25 01:12:33 【问题描述】:

我使用Gradle 来构建我的spring-boot 应用程序。我想要什么?

我有一个多模块应用程序,其中一些模块是spring-boot 应用程序。我想在父项目的 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'

我在每个模块中复制了这段代码。我读了Gradledocumentation 并看到了这个:

插件本身不会自动应用 Spring Dependency 管理插件了。相反,它确实对 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

【问题讨论】:

【参考方案1】:

您仍然需要为您的依赖项定义repositories。将以下行添加到您的 build.gradle。

repositories 
    mavenCentral()

【讨论】:

Spring-boot 和 Gradle:构建时间太长 - 如何调试?

】Spring-boot和Gradle:构建时间太长-如何调试?【英文标题】:Spring-bootandGradle:toolongbuildtime-howtodebug?【发布时间】:2016-02-0607:30:31【问题描述】:我有多部分项目,项目的API部分有大约10个依赖项。尝试使用SpringBoot(bootRun)运行API... 查看详情

如何使用 spring-boot gradle 插件进行 proguard

】如何使用spring-bootgradle插件进行proguard【英文标题】:howtoproguardwithspring-bootgradleplugin【发布时间】:2019-03-2308:41:08【问题描述】:如何使用springboot2和gradlebuild设置proguard混淆?你好。尝试使用其gradle插件和Proguardgradle插件设置Sp... 查看详情

使用 Gradle、Groovy 和 spring-boot 加载失败并出现 java.lang.NoSuchFieldException:classCache

】使用Gradle、Groovy和spring-boot加载失败并出现java.lang.NoSuchFieldException:classCache【英文标题】:springloadedwithGradle,Groovyandspring-bootfailswithjava.lang.NoSuchFieldException:classCache【发布时间】:2014-12-2720:48:44【问题描述】:我已经成功设置了... 查看详情

QueryDSL、spring-boot 和 Gradle

】QueryDSL、spring-boot和Gradle【英文标题】:QueryDSL,spring-boot&Gradle【发布时间】:2014-05-1112:06:07【问题描述】:我希望通过gradle将querydsl带入我的spring-boot项目。尽管在网上找到了几个例子,但由于依赖关系的问题(我认为),它... 查看详情

Gradle 5 JUnit BOM 和 Spring Boot 版本不正确

...rsions【发布时间】:2019-07-0301:17:56【问题描述】:我正在使用Gradle5的BOM(材料清单)feature。这就是我对JUnit5依赖项的描述方式:testImplementation(enforcedPlatform("org.junit:junit-b 查看详情

使用 spring-boot 的 assemble 创建的 jar 的 Gradle 集名称

】使用spring-boot的assemble创建的jar的Gradle集名称【英文标题】:Gradlesetnameforjarcreatedwithspring-boot\'sassemble【发布时间】:2021-06-1113:44:19【问题描述】:我想用gradle(kotlin-dsl)创建一个可执行的jar,我想给它一个自定义名称。对于可执... 查看详情

如何使用带有 gradle 的多个嵌入式服务器运行 spring-boot 集成测试

】如何使用带有gradle的多个嵌入式服务器运行spring-boot集成测试【英文标题】:howtorunspring-bootintegrationtestswithmultipleembededserverswithgradle【发布时间】:2016-11-0315:43:27【问题描述】:我对我的SpringBoot应用程序进行了一些集成测试。... 查看详情

如何在 Gradle 中为 Spring 使用 Maven BOM?

】如何在Gradle中为Spring使用MavenBOM?【英文标题】:HowtouseamavenBOMforSpringinGradle?【发布时间】:2019-05-0606:57:27【问题描述】:我正在将POM转换为Gradle,而我遇到的一件事是在Gradle中进行依赖管理,如下所示:<dependencyManagement>&... 查看详情

多模块 Gradle 项目 - 从 Spring-Boot 1.5 迁移到 2.1

】多模块Gradle项目-从Spring-Boot1.5迁移到2.1【英文标题】:Multi-ModuleGradleproject-MigratefromSpring-Boot1.5to2.1【发布时间】:2019-06-2610:13:43【问题描述】:我想将多模块spring-boot1.5项目迁移到spring-boot2.1。这是一个gradle项目(4.9),但不知... 查看详情

使用 QueryDSL 4.1.4 和 Intellij 的 Gradle

...04-1122:36:05【问题描述】:我试图让我的queryDSL1.4.1的Q类在Spring-Boot1.5.2项目中得到认可。IDE是IntellijUltimate。build.gradlebuildscriptextspringBootVersion=\ 查看详情

如何将 Gatling 与现有的 Spring-Boot + Gradle 应用程序集成

】如何将Gatling与现有的Spring-Boot+Gradle应用程序集成【英文标题】:HowtoIntegrateGatlingwithexistingSpring-Boot+Gradleapplication【发布时间】:2021-05-1705:06:19【问题描述】:我正在尝试集成Gatling以执行自动化负载测试。但我得到了不同的错... 查看详情

并行启动多个 Gradle "spring-boot" 插件 "bootRun" 任务

】并行启动多个Gradle"spring-boot"插件"bootRun"任务【英文标题】:LaunchmultipleGradle"spring-boot"plugin"bootRun"tasksinparallel【发布时间】:2014-06-3013:33:15【问题描述】:我有一个使用Gradle构建的多项目SpringBoot应... 查看详情

如何在 gradle 中获取 spring-boot 依赖版本?

】如何在gradle中获取spring-boot依赖版本?【英文标题】:Howtogetspring-bootdependencyversioningradle?【发布时间】:2017-07-0522:16:50【问题描述】:我有一个带有org.springframework.boot:spring-boot-gradle-plugin的标准spring-boot项目。我知道我可以用例... 查看详情

使用 Gradle 和 Spring Boot 时无法发布到本地 maven 存储库

...间】:2014-07-0304:14:45【问题描述】:我有一个非常简单的spring-boot(1.0.2)示例(基于http://spring.io/guides/gs/rest-service/)使用Gradle(1.12 查看详情

为啥 spring-boot 和 postgres 连接会在一段时间后断开?

】为啥spring-boot和postgres连接会在一段时间后断开?【英文标题】:whydoesspring-bootandpostgresconnectionbreaksaftercertaintime?为什么spring-boot和postgres连接会在一段时间后断开?【发布时间】:2015-12-2721:39:21【问题描述】:我使用tomcat-connect... 查看详情

Gradle 平台 BOM 设置版本选择性

】Gradle平台BOM设置版本选择性【英文标题】:GradleplatformBOMsetversionselectively【发布时间】:2021-03-0821:15:18【问题描述】:我创建Bom在这个BOM中限制了许多依赖项(例如io.github.microutils:kotlin-logging、ch.qos.logback:logback-classic)当我将... 查看详情

Gradle maven-publish 不构建独立的 spring-boot 应用程序

】Gradlemaven-publish不构建独立的spring-boot应用程序【英文标题】:Gradlemaven-publishdoesnotbuildstandalonespring-bootapplication【发布时间】:2014-11-3011:26:57【问题描述】:当我使用gradlebuild构建一个spring-boot应用程序(到一个独立的jar)时,... 查看详情

在父 build.gradle 中找不到 ID 为 spring-boot 的插件

】在父build.gradle中找不到ID为spring-boot的插件【英文标题】:pluginwithidspring-bootnotfoundinparentbuild.gradle【发布时间】:2016-02-0706:26:05【问题描述】:我有以下项目结构:java/构建.gradlesettings.gradle项目A/构建.gradle项目B/build.gradle当我输... 查看详情