【发布时间】:2021-05-18 22:49:21
【问题描述】:
我正在开发一个 cron,因为我正在使用 Web 客户端将发布请求发送到休息 api。我不想让嵌入式服务器保持打开状态,因为 cron 需要在几秒钟内完成它的任务。但是当我不使用服务器时:
spring.main.web-application-type=none
它显示错误Connection prematurely closed BEFORE response; nested exception is reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response
由于它需要服务器工作,我该怎么做才能在响应后停止服务器。
我试过了
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=20s
但它什么也没做(我正在使用 intellij ide)
更新: 我试过了
SpringApplication.exit(context, (ExitCodeGenerator) () -> 0);
但是得到Caused by: java.lang.IllegalStateException: org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@37c7595 has been closed already
【问题讨论】: