SpringBoot 程序启动后执行

示例:

package com.zyq.config;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * SpringBoot启动后,会执行下面 run 方法
 * 
 * @author Yuanqiang.Zhang
 * @since 2021年6月10日
 */
@Component
public class AppInit implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println(">>>>>>程序启动完毕>>>>>>>");
    }

}

效果:

2021-06-10 09:12:50.540  INFO 24716 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-06-10 09:12:50.669  WARN 24716 --- [  restartedMain] org.thymeleaf.templatemode.TemplateMode  : [THYMELEAF][restartedMain] Template Mode 'HTML5' is deprecated. Using Template Mode 'HTML' instead.
2021-06-10 09:12:50.817  INFO 24716 --- [  restartedMain] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
2021-06-10 09:12:50.870  INFO 24716 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2021-06-10 09:12:50.945  INFO 24716 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 80 (http) with context path ''
2021-06-10 09:12:50.949  INFO 24716 --- [  restartedMain] com.zyq.WebApp                           : Started WebApp in 4.038 seconds (JVM running for 4.672)
>>>>>>程序启动完毕>>>>>>>

 

相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页