spring 使用注解来调度定时任务
- 配置自动调度的包
@Configuration
@ComponentScan(basePackages = "com.test.indexer.service")
public class AppConfig {
}
2. 注解调度和定时任务
/**
* 定时任务
*/
@Component
public class ScheduledTasks { private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); @Scheduled(fixedRate = 5000)
public void reportCurrentTime() {
System.out.println("------------------The time now is " + dateFormat.format(new Date()));
}
}
3. 调用
@Configuration
@EnableAsync
@EnableScheduling
public class App {
// todo
}
spring 使用注解来调度定时任务的更多相关文章
- spring boot注解之@Scheduled定时任务实现
java实现定时任务一般使用timer,或者使用quartz组件.现在在spring boot提供了更加方便的实现方式. spring boot已经集成了定时任务.使用@Secheduled注解. @ ...
- 关于Spring mvc注解中的定时任务的配置
关于spring mvc注解定时任务配置 简单的记载:避免自己忘记,不是很确定我理解的是否正确.有错误地方望请大家指出. 1,定时方法执行配置: (1)在applicationContext.xml中 ...
- Spring通过注解方式实现定时任务
XML配置: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http:/ ...
- spring注解scheduled实现定时任务
只想说,spring注解scheduled实现定时任务使用真的非常简单. 一.配置spring.xml文件 1.在beans加入xmlns:task="http://www.springfr ...
- atititt.java定时任务框架选型Spring Quartz 注解总结
atititt.java定时任务框架选型Spring Quartz 总结 1. .Spring Quartz (ati recomm) 1 2. Spring Quartz具体配置 2 2.1. 增 ...
- 使用轻量级Spring @Scheduled注解执行定时任务
WEB项目中需要加入一个定时执行任务,可以使用Quartz来实现,由于项目就一个定时任务,所以想简单点,不用去配置那些Quartz的配置文件,所以就采用了Spring @Scheduled注解来实现了 ...
- 定时任务 spring @Scheduled注解
使用spring @Scheduled注解执行定时任务: 运行!!! 关于Cron表达式(转载) 表达式网站生成: http://cron.qqe2.com/ 直接点击 cronExpression ...
- Spring框架中的Quartz定时任务使用笔记(通过@Scheduled注解的方式实现)
1.修改spring的xml配置信息 applicationContext.xml 三个部分内容 1.xmlns添加:xmlns:task="http://www.springframewo ...
- Spring中使用注解 @Scheduled 执行定时任务
来自:http://blog.51cto.com/dwf07223/1557145 注解@Scheduled 可以作为一个触发源添加到一个方法中,例如,以下的方法将以一个固定延迟时间5秒钟调用一次执行 ...
随机推荐
- centos7安装后的防火墙问题
centos7 默认使用firewall作为防火墙 停止并关闭开机自启动: systemctl stop firewalld.service #停止firewall systemctl disable ...
- [HTML5] Add an SVG Image to a Webpage and Get a Reference to the Internal Elements in JavaScript
We want to show an SVG avatar of the patio11bot, so we'll do that in three ways: Using an img tag - ...
- JedisCluster操作redis集群demo
package com.chenk; import java.util.HashMap; import java.util.HashSet; import java.util.List; import ...
- 一个简单的int型C++单链表的实现
IntSLList.h //************************ intSLList.h ************************** // singly-linked list ...
- [置顶] 原创鼠标拖动实现DIV排序
先上效果图: 对比传统的排序,这是一个很不错的尝试,希望对大家有启发. 大家可以参考我的上一篇博文:http://blog.csdn.net/littlebo01/article/details/12 ...
- 05-spring-bean注入
spring中只有两大核心技术: 控制反转(IOC)&依赖注入(DI),AOP(面向切面编程) 依赖注入:指利用配置文件的关系,来决定类之间的引用关系,以及数据的设置操作. 构造方法注入 默认 ...
- Spring+Hibernate整合
因为整合spring和hibernate所以,需要用到spring里面复写Hibernate的类以有DI和IOC特性 db.sql hibernate_basic数据库 表 person 字段 pid ...
- FreeBSD Top States
转自:http://blog.csdn.net/fcoolx/article/details/4412196 select Process is blocked in the select(2) sy ...
- python ---用户输入
范例1:我们希望整数(整数),这就是为什么我们使用int()函数. x = int(raw_input("Enter x:")) y = int(raw_input("E ...
- Android studio 使用心得(六)—android studio 如何加载.so文件
之前一直没怎么注意,以为.so文件android为像eclipse一样直接加载,但是直到昨天我在android studio上调试公司项目推送消息的时候,才发现,.so文件原来没有加载成功. 可能之前 ...