gpt4 book ai didi

spring-boot - Gradle bootRun 从多模块项目中的父文件夹

转载 作者:行者123 更新时间:2023-12-03 02:56:35 24 4
gpt4 key购买 nike

我有我的 Gradle项目,它有2个模块:项目A和项目B,后者依赖于前者。请注意,这两个项目都是 Spring Boot应用程序,所以当我执行 gradle bootRun从他们各自的目录中,他们会很好地开始。

问题是当我执行 gradle bootRun 时,我想从父目录启动项目 A 的服务,它正在启动项目 B。似乎我缺少一些 Gradle配置。

build.gradle(项目 A)

group = 'com.oni'
version = '0.0.2-SNAPSHOT'
sourceCompatibility = 1.8



dependencies {
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile 'org.javassist:javassist:3.18.2-GA'
testCompile("de.flapdoodle.embed:de.flapdoodle.embed.mongo")
}

build.gradle(项目 B)
group = 'com.oni'
version = '0.0.2-SNAPSHOT'
sourceCompatibility = 1.8

dependencies {
def withoutInflux = { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-mongodb' }

compile project(':projectA'), withoutInflux
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.7'
}

build.gradle(父)
buildscript {
ext {
springBootVersion = '2.0.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}


subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'


repositories {
mavenCentral()
// mavenLocal()
}


dependencies {
implementation('org.springframework.boot:spring-boot-starter')
testImplementation('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.influxdb:influxdb-java')
compile('org.mockito:mockito-core')
compile('ma.glasnost.orika:orika-core:1.4.2')
compile 'com.google.guava:guava-annotations:r03'
}
}

settings.gradle(父)
rootProject.name = 'project'


include 'projectA'
include 'projectB'

提前致谢。

最佳答案

您可以使用

./gradlew :projectA:bootRun
./gradlew :projectB:bootRun

关于spring-boot - Gradle bootRun 从多模块项目中的父文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54697249/

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