我在嘗試ApplicationListener,但每次都調用ContextRefreshedEvent
。我想知道何時調用ContextStartedEvent
。ContextRefreshedEvent每次調用而不是ContextStartedEvent
public class CustomListener implements ApplicationListener{
@Override
public void onApplicationEvent(ApplicationEvent applicationEvent) {
if(applicationEvent instanceof ContextRefreshedEvent){
System.out.println("<><><>refresh event......");
}else if(applicationEvent instanceof ContextStartedEvent){
System.out.println("<><><><>started event......");
}else{
System.out.println("......else........");
}
}
}