1.实现方式

  1. 实现ApplicationRunner接口
  2. 实现CommandLineRunner接口
    @Component
    @Slf4j
    public class AfterServiceStarted implements ApplicationRunner{
    
        /**
         * 会在服务启动完成后立即执行
         */
        @Override
        public void run(ApplicationArguments args) throws Exception {
    
            log.info("Successful service startup!");
        }
    }
    @Component
    public class AfterServiceStartedOther implements CommandLineRunner{
    
        /**
         * 会在服务启动完成后立即执行
         */
        @Override
        public void run(String... args) throws Exception {
    
            JedisSingleton.getInstance().set("Service startup time", String.valueOf(System.nanoTime()));
        }
    }

     

相关文章:

  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2021-12-11
  • 2021-07-22
  • 2022-01-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-01-25
  • 2022-03-02
  • 2021-09-05
相关资源
相似解决方案