1.在springboot主启动类上添加@EnableScheduling注解
@EnableScheduling
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
创建一个在类中写一个方法加上@Scheduled(cron = “”)注解并配合cron表达式即可
@Scheduled(cron = "*/5 * * * * ?")
public void tset01() {
System.out.println("111111");
}
ok