I believe that you can register a listener as follows:
public static void main(String[] args) { SpringApplication app = new SpringApplication(WsBootClientApplication.class); app.addListeners(new ApplicationListener<ContextStartedEvent>() { @Override public void onApplicationEvent(ContextStartedEvent event) {
If ContextStartedEvent is not suitable for you, you can replace ContextStartedEvent with ApplicationEvent. This is more general and will handle all context life cycle events that the application can listen to.
source share