ssm定时任务
来源:互联网 发布:keen.min.js是干嘛的 编辑:程序博客网 时间:2024/05/14 22:11
1.spring-timer.xml<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/taskhttp://www.springframework.org/schema/task/spring-task-4.3.xsd"><!-- <context:component-scan base-package="com.sojson.common.timer;com.sojson.roadmanager.huifubao.timer" ><context:include-filter type="annotation" expression="org.springframework.stereotype.Component"/></context:component-scan>--> <!-- <bean id="systemTimer" class="com.sojson.common.timer.ToTimer"/><bean id="hfbTimer" class="com.sojson.roadmanager.huifubao.timer.HfbTimer"/><bean id="notifyTimer" class="com.sojson.zhifu.timer.NotifyTimer"/><task:executor id="executor" pool-size="5" /> <task:scheduler id="scheduler" pool-size="10" /> <task:annotation-driven executor="executor" scheduler="scheduler" /> <task:scheduled-tasks> <task:scheduled ref="hfbTimer" method="successOrderSelector" cron = "*/50 * * * * ?"/> </task:scheduled-tasks>--> <bean id="hjTimer" class="com.sojson.roadmanager.huiju.timer.HjTimer"/> <task:scheduled-tasks> <task:scheduled ref="hjTimer" method="updateHuijuDaiFuSuccess" cron = "0 0/10 * * * ?"/> </task:scheduled-tasks></beans>2.java类package com.sojson.roadmanager.huiju.timer;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.annotation.Resource;import org.springframework.scheduling.annotation.Scheduled;import com.sojson.common.utils.DateUtil;import com.sojson.roadmanager.huiju.service.HuiJuService;import com.sojson.zhifu.dao.SDaiFuMapper;import com.sojson.zhifu.model.SDaiFu;/** * 使用Spring订制的计划任务 * */// 此注解泛指一个spring组件而@Resource @Service是确指是哪种组件/* * @Component("hfbTimer") * @EnableScheduling */public class HjTimer { /* * 对应配置文件:spring-timer * 所有定时计划任务请在这里设定 * 如果不需要,请注释 * * 需要注意的几点: * 1、spring的@Scheduled注解 需要写在实现上 * 2、 定时器的任务方法不能有返回值(如果有返回值,spring初始化的时候会告诉你有个错误, * 需要设定一个proxytargetclass的某个值为true、具体就去百度google吧) * 3、实现类上要有组件的注解@Component 剩下的就是corn表达式了、具体使用以及参数请百度google * * CRON表达式 含义 * "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触发 * */ /* * @Resource RoleService roleService; */ /*@Scheduled(cron = "0/5 * * * * ?") // 5秒的测试不用注掉就行 @Resource HuiJuService huiJuService; @Resource SDaiFuMapper sDaiFuMapper; @Scheduled(cron = "0 0/10 * * * ?") // 每10分钟执行一次 public void updateHuijuDaiFuSuccess() { System.out.println("开启订单查询任务"); System.out.println(DateUtil.dateToStringWithTime()); System.out.println(Thread.currentThread().getName()); Map<String, Object> map = new HashMap<String, Object>(); map.put("status", 1); map.put("page_sql", "LIMIT 0,1000"); map.put("roadBankName", "xx"); List<SDaiFu> sDaiFuList = sDaiFuMapper.findAll(map);// 1000条订单 System.out.println("sDaiFuList.size()===" + sDaiFuList.size()); for (SDaiFu df : sDaiFuList) { String rb_Code = huiJuService.daifuHuiJuQuery(df.getBatchNo()); if (rb_Code.equals("100")) {// 交易成功 df.setStatus(2); sDaiFuMapper.update(df); } } }}
阅读全文
0 0
- ssm定时任务
- ssm框架的定时任务
- ssm+quartz创建定时任务
- ssm定时任务的实现
- 在SSM框架中配置定时任务
- SSM框架整合 quartz 定时任务调度
- 在SSM框架中配置定时任务
- ssm框架整合quartz实现定时任务
- ssm框架定时任务报错
- SSM框架整合 quartz 定时任务调度
- ssm框架利用timer类创建定时任务
- SSM集成Quartz定时任务 重复执行问题
- SSM基本搭建和定时任务的开启
- ssm项目中动态Quartz定时任务的实现(定时任务存在表中,而不是在.xml中)
- ssm(spring+springMVC+Mybatis)框架 集成Quartz(定时任务框架)
- Quartz 任务调度实例 定时的在SSM框架中的运用
- ssm框架开发定时任务到达某一个时间点自动更新数据
- 定时任务
- 欢迎使用CSDN-markdown编辑器
- 性能测试之 ab测试
- Ubuntu16.04下/etc/profile
- 数学算法
- Kafka设计解析(六)- Kafka高性能关键技术解析
- ssm定时任务
- Android转屏流程与优化(Google转屏算法)
- docker安装升级linux内核(2.6.32->3.10.81),安装成功!
- Vue 2.0 的变化(一)之基本 API 变化
- springboot启动方式
- 织梦m.二级域名手机站图片不显示不出来【亲测,可用】
- ubuntu16.04 + shadowsocks + Firefox/Chrome + switchomega+sslocal
- 欢迎使用CSDN-markdown编辑器(保留以备参考)
- 给zigbee的串口发送一个数据后,一直触发回调函数的解决办法