spring-boot学习笔记之Listener

spring-boot扩展了spring的ApplicationContextEvent,提供了五种事件

  • ApplicationStartingEvent:spring boot启动开始时执行的事件
  • ApplicationEnvironmentPreparedEvent:spring boot 对应Enviroment已经准备完毕,但此时上下文context还没有创建
  • ApplicationPreparedEvent:spring boot上下文context创建完成,但此时spring中的bean是没有完全加载完成的
  • ApplicationFailedEvent:spring boot启动异常时执行事件
  • ApplicationReadyEvent:该事件表示application应该初始化完成,可以准备接收请求


【spring-boot学习笔记之Listener】
http://www.jianshu.com/p/edd4cb960da7

【SpringApplication事件及Spring常用事件】
http://www.jianshu.com/p/73f95875557a

【springboot的ApplicationReadyEvent】
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent>, Ordered {

    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
        System.out.println("############started");
    }

    @Override
    public int getOrder() {
        return Ordered.LOWEST_PRECEDENCE;
    }
}

https://segmentfault.com/a/1190000008405515

【SpringBoot 原理 (二): run】
http://www.jianshu.com/p/692b10aef052

spring boot实战(第二篇)事件监听
http://blog.csdn.net/liaokailin/article/details/48186331

猜你喜欢

转载自rd-030.iteye.com/blog/2388464