【问题标题】:In Gradle build, start Spring boot application, run tests and then stop the Spring boot application在 Gradle 构建中,启动 Spring Boot 应用程序,运行测试,然后停止 Spring Boot 应用程序
【发布时间】:2017-04-14 02:10:33
【问题描述】:

通过我的 Gradle 构建,我想启动我的 Spring Boot 应用程序,运行一些测试,然后关闭 Spring Boot 应用程序。首先我尝试启动服务器然后关闭,暂时不做测试。

我的 build.gradle 文件的一部分看起来像这样

bootRun {
    systemProperties = System.properties
}

task shutdown(type: org._10ne.gradle.rest.RestTask) {
    httpMethod = 'post'
    uri = 'http://localhost:8080/shutdown'
}

task integrationTest() {
    dependsOn bootRun
    finalizedBy shutdown
}

我像这样从命令行开始构建

gradle integrationTest -Dendpoints.shutdown.enabled=true

构建启动了 Spring Boot 应用程序,但它没有继续(当然)关闭任务。我可以单独运行关闭任务,它将关闭 Spring Boot 应用程序。

但是,我怎样才能让服务器在同一个构建中运行和关闭?

【问题讨论】:

    标签: spring gradle spring-boot integration-testing


    【解决方案1】:

    我不确定它是否适用于像 bootRun 这样的任务,但我认为您正在寻找像 ParallelizableTask 这样的任务

    您还必须传递--parallel 命令行选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-24
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 1970-01-01
      • 2016-07-01
      • 2018-03-18
      • 2019-05-02
      相关资源
      最近更新 更多