SpringBoot 定时任务
作者:
夜空最亮的9星 | 来源:发表于
2018-08-28 05:18 被阅读17次
SpringBoot 定时任务
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
/**
* 定时任务配置类
*/
@Configuration
@EnableScheduling // 启用定时任务
public class SchedulingConfig {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Scheduled(cron = "0/20 * * * * ?") // 每20秒执行一次
public void scheduler() {
logger.info(">>>>>>>>>>>>> scheduled ... ");
}
}
本文标题:SpringBoot 定时任务
本文链接:https://www.haomeiwen.com/subject/jnwxwftx.html
网友评论