I port the application to Spring boot. My application is listening ContextStartedEvent, but it looks like Spring boot is not generating such an event. I can change my application and listen ApplicationReadyEvent, but according to the spring boot document , the "old" events are still emitted.
I would like to keep my code intact as much as possible.
Question: is ContextStartedEvent supported using Spring boot or not?
Demo:
@EnableAutoConfiguration
public class EventExample {
@EventListener(classes = ContextStartedEvent.class)
void start() { System.out.println("Listen ContextStartedEvent");}
@EventListener(classes = ApplicationReadyEvent.class)
void start2(){System.out.println("Listen ApplicationReadyEvent");}
public static void main(String[] args) throws Exception {
SpringApplication.run(EventExample.class, args);
}
}
Exit
Listen to ApplicationReadyEvent
source
share