1.创建java类SchedulingConfig
[email protected]
[email protected]
[email protected](cron = “0/20 * * * * ?”) // 每20秒执行一次
具体代码如下
package cn.wuyang.springboot.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
/**
* 定时任务
* [email protected]
* [email protected]
* [email protected](cron = "0/20 * * * * ?") // 每20秒执行一次
* @author wuyang
*
*/
@Configuration
@EnableScheduling
public class SchedulingConfig {
@Scheduled(cron = "0/20 * * * * ?") // 每20秒执行一次
public void SchedulingTest() {
System.out.println(">>>>>>>>> SchedulingConfig.scheduler()");
}
}
5.启动查看
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/11251.html