【问题标题】:Gradle bootRun from parent folder in multi-module projectGradle bootRun 从多模块项目中的父文件夹
【发布时间】:2019-07-08 21:12:58
【问题描述】:

我有我的Gradleproject,它有 2 个模块:project Aproject 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'

提前致谢。

【问题讨论】:

    标签: spring-boot gradle


    【解决方案1】:

    你可以使用

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

    【讨论】:

      猜你喜欢
      • 2018-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-10
      • 2021-12-30
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      相关资源
      最近更新 更多