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

标签 spring-boot gradle

我有我的 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/

相关文章:

java - 如何在 Spring Boot 中将页面重定向到静态文件?

java - Spring Boot 如何在验证@PathVariable 参数时返回自定义错误消息

android - 将 Eclipse 项目迁移到 Gradle

Android Studio 无法与 gradle 文件同步

java - Windows、Gradle 和 Cucumber 组合在生成报告时抛出 IOException

spring - 如何在 Spring Boot 中选择性地升级依赖项? (样例: Spring Data)

java - Spring Boot 映射子文件夹的资源

java - 如何使用Spring云数据流转换Mysql数据http调用?

java - Gradle:如何列出所有 "given tests"

intellij-idea - gradle & Idea 自动导入 : Project resolve error