使用SpringMVC自带的@Scheduled完成定时任务
package com.practice.prac.service.Impl; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date; import javax.annotation.Resource; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import com.practice.prac.dao.CreateTableByDayMapper;
import com.practice.prac.service.CreateTableByDayService; @Service("CreateTableByDayService")
@Component
public class CreateTableByDayImpl implements CreateTableByDayService { @Resource
CreateTableByDayMapper createTableByDayMapper; @Override
@Scheduled(cron = "*/5 * * * * ?")
public void createTable() { DateFormat fmt = new SimpleDateFormat("yyyyMMdd");
String time = fmt.format(new Date());
String sql = "create table if not exists table_name_" + time
+ " (name varchar(50),value varchar(50))";
createTableByDayMapper.createTable(sql);
} }
CreateTableByDyImpl.java
"0 0 12 * * ?" 每天中午十二点触发
"0 15 10 ? * *" 每天早上10:15触发
"0 15 10 * * ?" 每天早上10:15触发
"0 15 10 * * ? *" 每天早上10:15触发
"0 15 10 * * ? 2005" 2005年的每天早上10:15触发
"0 * 14 * * ?" 每天从下午2点开始到2点59分每分钟一次触发
"0 0/5 14 * * ?" 每天从下午2点开始到2:55分结束每5分钟一次触发
"0 0/5 14,18 * * ?" 每天的下午2点至2:55和6点至6点55分两个时间段内每5分钟一次触发
"0 0-5 14 * * ?" 每天14:00至14:05每分钟一次触发
"0 10,44 14 ? 3 WED" 三月的每周三的14:10和14:44触发
"0 15 10 ? * MON-FRI" 每个周一、周二、周三、周四、周五的10:15触发
使用SpringMVC自带的@Scheduled完成定时任务的更多相关文章
- spring的Scheduled(定时任务)和多线程
一.前言 在我们日常的开发中,经常用到数据同步的更新,这时我们采用的是spring的定时任务和java的多线程进行数据的更新,进行时实的服务调用. 二.实现思路 1.创建线程类 ...
- spring注解scheduled实现定时任务
只想说,spring注解scheduled实现定时任务使用真的非常简单. 一.配置spring.xml文件 1.在beans加入xmlns:task="http://www.springfr ...
- 定时任务-----Springboot中使用Scheduled做定时任务----http://www.cnblogs.com/lirenqing/p/6596557.html
Springboot中使用Scheduled做定时任务---http://www.cnblogs.com/lirenqing/p/6596557.html 已经验证的方案: pom文件加入依赖 < ...
- SpringBoot中使用@Scheduled创建定时任务
SpringBoot中使用@Scheduled创建定时任务 定时任务一般会在很多项目中都会用到,我们往往会间隔性的的去完成某些特定任务来减少服务器和数据库的压力.比较常见的就是金融服务系统推送回调,一 ...
- SpringBoot使用@Scheduled创建定时任务
定时任务一般会存在中大型企业级项目中,为了减少服务器.数据库的压力往往会采用时间段性的去完成某些业务逻辑.比较常见的就是金融服务系统推送回调,一般支付系统订单在没有收到成功的回调返回内容时会持续性的回 ...
- 使用Spring的@Scheduled实现定时任务
Spring配置文件xmlns加入xmlns:task="http://www.springframework.org/schema/task"xsi:schemaLocation ...
- Springboot中使用Scheduled做定时任务
在开发中,定时任务是常见的功能,在spring boot 下开发定时任务其实很简单,具体代码如下: 1.配置依赖包pom.xml 由于默认的maven仓库经常访问不了,这里采用了阿里云的maven仓库 ...
- 使用Spring的@Scheduled实现定时任务参数详解
Spring配置文件xmlns加入 xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocati ...
- SpringBoot之使用Scheduled做定时任务
定时任务有好多开源框架比如Quartz,@Scheduled是Spring的一个定时任务注解,通过注解配置就能够轻量级的定时任务,简单方便. 一.@Scheduled注解介绍 这里先贴上@Schedu ...
随机推荐
- OC开发_Storyboard——绘制和视图
1.绘制 不要调用drawRect.调用setNeedsDisplay相当于告知系统视图需要重绘, 它会去调用drawRect,更新屏外缓冲器 2.UIBezierPath绘制图形, 设置图像op ...
- mysql 一对多,多对多
一对多 一对多与多对一是一个概念,指的是一个实体的某个数据与另外一个实体的多个数据有关联关系. 班级表(一表) 名称 教室 总人数 学科 PHP141115 A814 53 PHP PHP140925 ...
- Win7系统右上角没有搜索怎么办?Win7找回资源管理器中的搜索框
最近有win7系统用户发现打开资源管理器,文件夹等右上角没有搜索框,这让人十分不方便无法进行搜索,那么如何找回呢?下面小编就分享一下方法给大家.推荐 最好用的Win7系统下载 操作步骤: 1.打开Wi ...
- ubuntu low graphic mode---disable docker -self start.
--------- /etc/default/docker.conf-----设置启动参数. /etc/init/docker.conf------------不好使(only mysql) star ...
- Mongo副本集的配置以及php node.js连接使用副本集
最近弄了下mongodb的副本集, 首先说下没有认证情况的副本集,相对比较简单,因为环境有限,我在同一台服务器上做了模拟. --rest参数是打开web监控页面,比如我们这里监听37017端口,则打开 ...
- 基于Nginx+FastDFS搭建图片文件系统
Nginx+fastdfs:https://www.cnblogs.com/chiangchou/p/fastdfs.html#_label0_1 缩略图:https://blog.csdn.net/ ...
- leetcode之Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ret ...
- Nginx 使用总结
一.使用 nginx 实现 灰度发布 灰度发布,现在是很多大项目的一个标配运维特性,我们可以将一个“新的版本代码”发布到集群中的少数几台(组)机器上,以便引入线上少量真实用 户进行测试,用于验证产品改 ...
- 2014年百度之星程序设计大赛 - 资格赛 1001 Energy Conversion
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/sr19930829/article/details/26003661 Energy Conversi ...
- React Native教程
React Native 中文网 http://reactnative.cn/ 相关资料======================= React-Native学习指南 https://github ...