我正在尝试ApplicationListener,但是每次都调用一个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........");
       }
    }

}

最佳答案

该链接可能对您有帮助:

http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/beans.html#context-functionality-events

09-11 20:51