sva*_*ret 6 spring integration-testing gradle spring-boot
通过 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
}
Run Code Online (Sandbox Code Playgroud)
我像这样从命令行开始构建
gradle integrationTest -Dendpoints.shutdown.enabled=true
Run Code Online (Sandbox Code Playgroud)
构建会启动 Spring Boot 应用程序,但它不会(当然)继续执行关闭任务。我可以单独运行关闭任务,它将关闭 Spring Boot 应用程序。
但是,如何让服务器在同一个构建中运行和关闭?
| 归档时间: |
|
| 查看次数: |
2366 次 |
| 最近记录: |