我是靠谱客的博主 爱笑冥王星,这篇文章主要介绍Springboot启动时执行任务CommandLineRunner,现在分享给大家,希望可以做个参考。

在Springboot程序启动时往往需要执行响应的任务,我们可以通过实现CommandLineRunner接口重写run方法达到对应的效果:

@Component
@Order(value=1)
//order为启动执行顺序
public class StartRunner implements CommandLineRunner {

    private static final Logger LOGGER = LoggerFactory.getLogger(StartRunner.class);
    @Override
    public void run(String... args) throws Exception {
       //代码块
    }
}

最后

以上就是爱笑冥王星最近收集整理的关于Springboot启动时执行任务CommandLineRunner的全部内容,更多相关Springboot启动时执行任务CommandLineRunner内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(134)

评论列表共有 0 条评论

立即
投稿
返回
顶部