@Component @PostConstruct @Order ApplicationRunner CommandLineRunner

时间:2021-06-29 13:18:19   收藏:0   阅读:15

@Component中static优先于@PostConstruct优先于ApplicationRunner优先于CommandLineRunner

  1. @Component 优先执行
    • @Order可执行执行顺序:数字越小,优先级越高,也就是@Order(1)注解的类会在@Order(2)注解的类之前执行。
      @Order(value=1)
      @Order(value=2)
      @Order(value=3)
    • static 优先执行
    • @PostConstruct 在static完成后执行
  2. @Component implements ApplicationRunner 容器启动完成后 @Component完成后 执行
  3. @Component implements CommandLineRunner 容器启动完成 @Component完成后 ApplicationRunner 完成后 最后执行

原文:https://www.cnblogs.com/mjtabu/p/14949390.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!