In spring boot web application, is it possible to ensure some code is executed before the embedded webserver (tomcat) is listening for incoming requests?
I have some data base migration scripts that need to be run before any request from my REST API is responded by the application. How can I do that? For now, my migration script component uses @EventListener
for ContextRefreshedEvent
but that is too late. The following line is already logged before:
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8091 (http) with context path ''