ApplicationReadyEvent Posted on 2018-08-08 | Edited on 2018-08-26 | In Spring框架 | Comments: | Views: ApplicationReadEvent 事件的来源是SpringApplication,事件发生时,所有的初始化步骤都已经完成。 用法12345678910111213@Componentpublic class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent>, Ordered { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { System.out.println("############started"); } @Override public int getOrder() { return Ordered.LOWEST_PRECEDENCE; }} 配合EventListener使用12345678@Componentclass MyClassWithEventListeners { @EventListener({ApplicationReadyEvent.class}) void contextRefreshedEvent() { System.out.println("event happened"); }}