Spring定时器spring task踩过的坑
来源:互联网 发布:晨枫网络是干嘛的 编辑:程序博客网 时间:2024/06/07 06:59
首先需要在配置文件中添加命名空间及描述(第一次忘记添加错了好多错误)
xmlns:task="http://www.springframework.org/schema/task" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
添加配置(任意网上搜索到的)
<!--开启这个配置,spring才能识别@Scheduled注解 --> <task:annotation-driven scheduler="qbScheduler" mode="proxy"/> <task:scheduler id="qbScheduler" pool-size="10"/>
添加Spring扫描
<context:component-scan base-package="你的路径要扫描注解的" />
整个Spring配置文件就结束了,然后进行POJO类编写
@Componentpublic class TaskJob { // 每五秒执行一次 @Scheduled(cron = "0/5 * * * * ?") public void TaskJob2() { System.out.println("定时器开始"); }}
这里用来测试使用的是cron 关于cron如下:
每隔5秒执行一次:*/5 * * * * ? 每隔1分钟执行一次:0 */1 * * * ? 每天23点执行一次:0 0 23 * * ? 每天凌晨1点执行一次:0 0 1 * * ? 每月1号凌晨1点执行一次:0 0 1 1 * ? 每月最后一天23点执行一次:0 0 23 L * ? 每周星期天凌晨1点实行一次:0 0 1 ? * L 在26分、29分、33分执行一次:0 26,29,33 * * * ? 每天的0点、13点、18点、21点都执行一次:0 0 0,13,18,21 * * ?
大佬们看见多多指导,作为技术储备留用。。。。
阅读全文
0 0
- Spring定时器spring task踩过的坑
- spring task定时器的运用
- spring task定时器的运用
- spring 自带的定时器task
- Spring自带的定时器task
- [Java定时器]用Spring Task实现一个简单的定时器.
- Spring Task的坑
- spring Task定时器的实际应用(重要)
- Spring的两种定时器-task和quartz
- spring注解调用task定时器服务
- spring定时器Task注解方式配置
- Spring任务调度<task:scheduled-tasks>(定时器)
- spring task(定时器) 使用注解方式
- Spring+HBase+phoenix踩过的坑
- spring cloud 前人踩过的坑
- spring定时器的配置
- spring的定时器管理
- spring的定时器
- opencv 16 OCR 端到端场景文本检测与识别(webcam_demo) vs2015
- FastJson基本用法
- Java SE(四)——对象、类、接口 (第二个版本)
- ConfigReader(四十八)—— ReadSkillArea
- MVC程序设计实例
- Spring定时器spring task踩过的坑
- 【Android】Retrofit 2.0 的使用
- IPC机制系列之三 Android中的IPC方式 (ContentProvider,Socket)
- H
- openstack判断是否支持numa
- 数据结构|顺序队列的实现(实验3.3)
- jQuery EasyUI 报错:Cannot read property length of XXX
- bzoj 2121 字符串游戏(字符串dp)
- ios 条件编译随笔代码