Spring Boot定时任务注解demo
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@Configuration // 声明类为系统配置类
@EnableScheduling // 开启调度任务
public class Test {
@Scheduled(cron = "0 0/1 * * * ?") // 定义调度器
public void job1() {
System.out.println("this is my first job execute");
}
}

浙公网安备 33010602011771号