SpringBoot集成@Scheduled()定时任务
2021-02-09 07:15
标签:定时 size oid color actor class tor style test 1.启动类增加注解: @EnableScheduling 2.定时任务类增加注解:@Component :将当前类实例化注入到容器中 3.定时方法增加注解:@Scheduled(cron = "* */5 * * * ?") SpringBoot集成@Scheduled()定时任务 标签:定时 size oid color actor class tor style test 原文地址:https://www.cnblogs.com/BenNiaoXianFei/p/12752645.html
@ComponentScan({"com.xxx.test"})1 @EnableScheduling
2 @ComponentScan({"com.xxx.test"})
3 @SpringBootApplication
4 public class MainApplication {
5 public static void main(String[] args) {
6
7 SpringApplication.run(MainApplication.class, args);
8 }
1 @Component
2 public class JobTest {
3
4 private static Logger log = LoggerFactory.getLogger(JobTest.class);
5
6 /**
7 * 秒、分、时、日、月、年
8 */
9 @Scheduled(cron = "* */5 * * * ?")
10 public void scheduleTest() {
11 log.info("系统定时任务测试开始");
12
13 //TODO
14
15 log.info("系统定时任务测试结束");
16 }
上一篇:Java泛型
文章标题:SpringBoot集成@Scheduled()定时任务
文章链接:http://soscw.com/index.php/essay/52983.html