I want to show my some static HTML page while spring context initializes. It should be visible when application starts and before spring context refreshed. I tried to use this manual as example https://www.nurkiewicz.com/2015/09/displaying-progress-of-spring.html but this doesn't work. I need to start embedded jetty directly when jetty is initialized. But spring boot starts embedded jetty only when context refreshed. I believe that there is should be the ability to start the embedded server after its initialized, not after the context refreshed only.

Comment From: wilkinsona

Thanks for the suggestion.

How would you expect those static HTML pages to be served by the application? By default, in a typical Spring Boot application, static resources are served by the resource handling support that's provided by Spring MVC or Spring WebFlux. This support is heavily bean-based and, therefore, cannot be used before the application context has been refreshed and the necessary beans are available for use.

Even with support for serving static HTML pages before the application context has completed its refresh, there would still be a period of time when the JVM is running but the pages could not be served while the embedded server is initialised. It's impossible to completely close this window with a solely application-based solution. In my opinion, a better solution is for a load balancer or proxy to be able to serve static content when no backend nodes are available to handle a request. This completely eliminates the period where an application JVM has been started but is not yet able to handle requests and serve responses.

Comment From: raccoon1515

My solution. https://stackoverflow.com/a/65842493/11634885

Comment From: wilkinsona

Thanks for sharing your solution.