使用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 ...
随机推荐
- 封装自己的getClass
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 160225、解决纯js文件国际化的问题
1.js中国际化 function test(){ alert("<s:text name='jsp.loading'/>"); } 2.最近在做strut ...
- 03Del.ashx(删除班级)
03Del.ashx 数据库里定义个BOOL型,TRUE表示正常FALSE表示删除 using System; using System.Collections.Generic; using Syst ...
- php 函数__autoload与spl_autoload_register理解
理解自:http://www.cnblogs.com/myluke/archive/2011/06/25/2090119.html __autoload的作用:当我们在一个页面使用其他文件的类方法时候 ...
- Django之views.py详解
http请求中产生的两个核心对象: http请求:HttpRequesthttp响应:HttpResponse 所在位置:from django.http import HttpRequest,Htt ...
- C# WinForm实现任务栏程序图标闪烁
相信大家在用QQ的时候都会知道,你打开了QQ聊天窗口,如果窗口不是当前激活的窗口的话,收到QQ消息时,任务栏(不是托盘图标)上的图标会闪一下变成黄色(Win7默认主题下),用以通知用户有消息进来了,之 ...
- Oil Skimming---hdu4185(最大匹配)
题目链接 题意:有一个地图.代表水#代表油每个单元格是10*10的,现有10*20的勺子可以提取出水上漂浮的油,问最多可以提取几勺的油: 每次提取的时候勺子放的位置都要是油,不然就被污染而没有价值了: ...
- DZNEmptyDataSet 使用
gitHub地址:https://github.com/dzenbot/DZNEmptyDataSet 效果图: 代码: #import "UIScrollView+EmptyDataSet ...
- 002-and design-dva.js 知识导图-01JavaScript 语言,React Component
一.概述 参看:https://github.com/dvajs/dva-knowledgemap react 或 dva 时会不会有这样的疑惑: es6 特性那么多,我需要全部学会吗? react ...
- POJ1845:Sumdiv(求因子和+逆元+质因子分解)好题
题目链接:http://poj.org/problem?id=1845 定义: 满足a*k≡1 (mod p)的k值就是a关于p的乘法逆元. 为什么要有乘法逆元呢? 当我们要求(a/b) mod p的 ...