【发布时间】: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