启动系统任务
小于 1 分钟Spring全家桶SpringBoot精讲细讲
实现了CommandLineRunner
和ApplicationRunner
这两个接口的类会在系统启动之后自动调用run方法。
Redis预热、系统检查等
CommandLineRunner
@Order(1)
@Component
public class CommandRunnerOne implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
System.out.println("CommandLineRunner start...");
}
}
ApplicationRunner
@Order(2)
@Component
public class CommandRunnerTwo implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("ApplicationRunner start...");
}
}
