SpringBoot学习记录----如何启动时执行任务(CommandLineRunner和ApplicationRunner)

SpringBoot提供了CommandLineRunner和ApplicationRunner接口,让咱们能够在启动项目时自动运行某些特定代码。例如一些数据的初始化,或者提早获取一些第三方接口的token。这两个接口都须要实现run方法,并以相同的方式工做。这个run方法在SpringApplication.run()完成以前调用。java 一、准备工做 首先,建立一个maven项目,如何建立m
相关文章
相关标签/搜索