ApplicationEvent
–ApplicationContextEvent
|- ContextStartedEvent 应用关闭事件
|- ContextRefreshedEvent 应用刷新事件
|- ContextClosedEvent 应用开启事件
|- ContextStoppedEvent 应用停止事件
– 扩展了两个实现:
1、EmbeddedServletContainerInitializedEvent 内嵌Servlet容器初始化事件
2、ApplicationReadyEvent:Spring Application 启动完成事件
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.ContextStoppedEvent;
@Slf4j
public class AppApplicationListener implements org.springframework.context.ApplicationListener {
@Override
public void onApplicationEvent(ApplicationEvent event) {
log.info("++++++++++++++++++++++++++++++++++++++++++");
if (event instanceof ContextStartedEvent) {
log.info("===============:{}", "BBQ 应用启动了!ÿ