gpt4 book ai didi

spring - Gradle有条件地运行多个 Spring 项目

转载 作者:行者123 更新时间:2023-12-03 05:54:28 25 4
gpt4 key购买 nike

我有多个使用 Spring 和 Spring 靴的项目。
Spring Boot具有使用Gradle运行应用程序的命令:

gradle bootRun

我可以使用以下命令运行所有应用程序:
gradle bootRun --parallel

但是我需要首先启动我的一个项目(我们称其为项目A),只有在启动后(项目A),其他项目才能启动。

问题是,我不明白如何启动项目A,然后等到它启动后,才开始其他项目。

如果我只是链接任务,那将无法正常工作,因为项目A继续运行并且没有将控制权交还给gradle。

以下项目之一的Grdale配置:
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

jar {
group 'test one'
}


sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
compile(
'org.springframework.boot:spring-boot-starter-data-jpa'
)
}

Main setting.gradle仅包含我的项目列表:
rootProject.name = 'best-app'    
include 'project A'
include 'project B'
include 'project C'

最佳答案

创建一个等待A完全启动然后完成的任务,然后使除bootRun之一之外的所有A任务都依赖于此任务。

关于spring - Gradle有条件地运行多个 Spring 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45798676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com