ScheduledTasks(定时任务)
来源:互联网 发布:linux数据库启动命令 编辑:程序博客网 时间:2024/06/02 05:20
spring框架的Scheduling Tasks学习demo
在上一篇ssm框架中添加一些内容
1.目录截图
2.在springmvc中添加task以及任务扫描注解以及扫描的test包
<context:component-scan base-package="com.fyl.smm.controller,com.fyl.smm.test"/> <task:annotation-driven/>
3.TestScheduledTasks类内容(每隔5秒在控制台输出一条语句)
package com.fyl.smm.test;import java.text.SimpleDateFormat;import java.util.Date;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component;@Component //(把普通pojo实例化到spring容器中,相当于配置文件中的<bean id="" class=""/>)public class TestScheduledTasks { private static final Logger log = LoggerFactory.getLogger(TestScheduledTasks.class); private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); @Scheduled(fixedRate = 5000) //执行定时任务 public void reportCurrentTime() { log.info("The time is now {}", dateFormat.format(new Date())); }}
每天记录自己学习的点滴
阅读全文
0 0
- ScheduledTasks(定时任务)
- quartz(定时任务)
- (7)定时任务
- 定时任务(java)
- mysql 定时事件(定时任务)
- laravel 任务调度(定时执行任务)
- 定时任务(计划任务)at&crontab
- Spring Boot 计划任务(定时任务)
- spring 定时任务(3)--配置多个定时任务
- java定时任务(三):timerTask定时任务
- JAVA定时执行任务(Tomcat 下的定时任务)
- oracle定时任务(dbms_job)
- 定时任务 java(实例)
- spring 定时任务(1)
- spring 定时任务(2)
- 定时任务调度(mongoDB)
- spring定时任务(二)
- spring 定时任务(一)
- xss explained
- WGAN-GP代码注释
- Linux 包管理工具
- 打劫房屋I
- Java 开发环境配置
- ScheduledTasks(定时任务)
- js中引用类型之日期
- ArcEngine 图层标注 (根据字段、角度)
- error C4996: 'sprintf': This function or variable may be unsafe 解决方法
- python爬虫获取淘宝妹子信息和相片
- Android解决UnsupportedOperationException异常!
- python---dictionary
- 517.Super Washing Machines
- 温故而知新系列:Java反射机制详解