I am developing a cron in that i am using a web client to send a post request to a rest api. I don't want to keep the embedded server on, as cron need to complete its task, in few seconds. But when i don't use the server by:
spring.main.web-application-type=none
it shows the error Connection prematurely closed BEFORE response; nested exception is reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response
as it need the server to work, what can i do to stop the server after the response.
I have tried
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=20s
but its not doing anything (i am using intellij ide)
Update: I tried
SpringApplication.exit(context, (ExitCodeGenerator) () -> 0);
But getting Caused by: java.lang.IllegalStateException: org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@37c7595 has been closed already