import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class MyStartupRunner implements CommandLineRunner {
// 项目启动后,就执行的功能
public void run(String... a) throws Exception{
while(true){
System.out.println("服务启动就执行的功能");
Thread.sleep(3000);
}
}
}
实现 CommandLineRunner 接口,重写 run 方法。
参考: www.cnblogs.com/myblogs-miller/p/9046425.html