SpringBoot 设置服务一启动就执行、初始化数据
作者:互联网
定义一个类实现ApplicationRunner
接口,然后Override这个ApplicationRunner
接口的run方法
@Component public class TaskRunner implements ApplicationRunner { public static final Logger log = LoggerFactory.getLogger(TaskRunner.class); @Override public void run(ApplicationArguments args) throws Exception { //初始化 } }
标签:初始化,TaskRunner,run,SpringBoot,class,设置,Override,ApplicationRunner,public 来源: https://www.cnblogs.com/pxblog/p/14995261.html