spring boot 初始化先后顺序

代码红了一大片 / 2023-05-05 / 原文

初始化方法

  1. @PostConstruct
  2. InitializingBean
  3. CommandLineRunner
  4. ApplicationRunner

先后顺序

@PostConstruct > InitializingBean > CommandLineRunnerApplicationRunner

项目启动执行一次

CommandLineRunnerApplicationRunner

通过@Order控制先后顺序,越小越先执行