SpringBoot定时任务的使用
来源:互联网 发布:数控刨槽机编程方法 编辑:程序博客网 时间:2024/05/20 07:53
创建类
package com.example.demo.scheduling;import org.springframework.scheduling.annotation.EnableScheduling;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component;@Component@EnableSchedulingpublic class SchedulingConfig {@Scheduled(cron = "0/20 * * * * ?") //每20秒执行一次public void scheduler() { System.out.println(">>>>>>>>> SchedulingConfig.scheduler()"); }}
入口类
package com.example.demo;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.ConfigurableApplicationContext;import com.example.demo.scheduling.SchedulingConfig;@SpringBootApplicationpublic class SpringBootJspApplication {public static void main(String[] args) {//获得ioc容器ConfigurableApplicationContext context=SpringApplication.run(SpringBootJspApplication.class, args);//获得SchedulingConfig类SchedulingConfig sc=context.getBean(SchedulingConfig.class);//调用方法sc.scheduler();//context.close();}}
运行结果
阅读全文
1 0
- springboot定时任务的使用
- SpringBoot 定时任务的使用
- SpringBoot定时任务的使用
- springboot定时任务使用
- springboot使用定时任务、异步
- SpringBoot定时任务的设置
- 二、springboot项目的简单使用之:定时任务
- Springboot 之 使用Scheduled做定时任务
- eclipse 使用maven构建springboot+定时任务
- Springboot使用定时任务,Spring Schedule
- SpringBoot 使用Scheduled 定时任务入门
- Springboot使用定时任务,Spring Schedule
- Springboot之使用Scheduled做定时任务
- SpringBoot定时任务说明
- springboot定时任务
- springboot(九):定时任务
- springboot(九):定时任务
- springboot 定时任务
- jQuery DOM操作之插入节点
- 数据结构之图
- zynq学习笔记三:生成BOOT.BIN
- weblogic的集群与配置
- jsp-创建及获取客户的会话信息
- SpringBoot定时任务的使用
- RESTful API 文档生成神器
- Linux命令详解详解之mkdir
- ACM-10月1日周日周末训练心得
- C语言实验——交换两个整数的值(顺序结构)
- 数组中出现次数超过长度一半的数字
- 堆
- 算法导论--逆序对
- 学习Linux基本命令60个(上)