从多模块项目中的父文件夹开始Gradle bootRun

时间:2019-02-14 18:51:57

标签: spring-boot gradle

我有我的 <div class="allProjects"> <div class="container prjct"> <div class="projects" id="project2"> </div> </div> <div class="container prjct"> <div class="projects" id="project3"> </div> </div> <div class="container prjct"> <div class="projects" id="project4"> </div> </div> </div> 项目,它有2个模块:项目A 项目B ,后者取决于前者。请注意,两个项目都是Gradle应用程序,因此当我从它们各自的目录中执行Spring Boot时,它们将正常运行。

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

build.gradle(项目A)

Gradle

build.gradle(项目B)

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(父级)

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'
}

settings.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'
    }
}

谢谢。

1 个答案:

答案 0 :(得分:2)

您可以使用

来运行它
./gradlew :projectA:bootRun
./gradlew :projectB:bootRun