Spring boot指定时间触发方法
1、创建一个spring boot项目启动时运行的类
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class MyCommandLineRunner implements CommandLineRunner {
@Override
public void run(String... var1) throws Exception{
System.out.println("This will be execute when the project was started!");
new DemoController().demo();
}
}
2、编写指定时间触发方法
import java.time.LocalDateTime;
import java.time.temporal.