简单说下基本配置:
applicationContext-task.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.chinacache.oss.facade.resource" /><!--需要扫描的包-->
<task:annotation-driven/> <!-- 这句是重点 定时器开关-->
</beans>
配置好后,有两种方式可以实现定时任务执行,我倾向于注解这种:
@Scheduled(fixedDelay = 3000)
public void process() {
System.out.println("hello,jizhong,now is: " + new Date());
}
这样,在程序环境中配置好后,每隔3秒将执行一次该方法。
另一种方式如下:
在applicationContext-task.xml追加如下内容,即可。
<task:scheduled-tasks>
<task:scheduled ref="simpleProcessor" method="process" cron="3/10 * * * * ?"/>
</task:scheduled-tasks>
分享到:
相关推荐
Independent Task Scheduling
Task Scheduling for Multi-Core and Parallel Architectures-Springer(2017).
This book presents task-scheduling techniques for emerging complex parallel architectures including heterogeneous multi-core architectures, warehouse-scale datacenters, and distributed big data ...
云计算中融入贪心策略的调度算法研究,周舟,胡志刚,鉴于Min-Min算法优先调度小任务而Max-Min算法优先调度大任务而导致云系统资源不平衡的问题,提出了一种新的算法叫Min-Max. Min-Max算法对时
In order to simulate the real traffic on the network, the entropy optimized based task scheduling model is proposed. Firstly, the capacity of the virtual machine which executes the task is computed ...
Task scheduling veta kkk lll llll
使用 Spring 中的 TaskScheduler 来启动/停止任务。
Soft Aperiodic Task Scheduling on Hard Real-Time Multiprocessor Systems
Quartz Net.Core 3.0 实现方便的定时任务 简约版框架 方便调用,Quartz 这个任务调度,挺不错的,就是,创建任务的时候,每次都得定义一个Ijob 类,来执行,比较麻烦。我这边通过一个简单的封装实现对任务的轻松调用...
今天小编就为大家分享一篇Laravel框架实现定时Task Scheduling例子,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
Spring排程(Scheduling)技术 1、排程(Scheduling)原理 2、什么是Timer 1)、执行一次 2)、周期执行 3、在spring中使用Timer 4、在spring中使用Quartz调度器
Power constraint communication-aware task scheduling in reconfigurable multiprocessors
在分布式系统中使用混洗遗传算法进行任务调度。 基于 Hosseini 论文: 侯赛尼,M.(2018 年)。 异构分布式系统中一种新的基于随机遗传的任务调度算法。 计算机研究进展杂志,9(4),19-36。
操作系统scheduling java仿真,包含FCFS,SHORTEST JOB FIRST, ROUND ROBIN method,PRIORITY
Security-aware task scheduling using untrusted components in high-level synthesis
14: Managing scheduling and concurrency 15: Spring Integration and the rich web 16: Messaging and batch operations 17: Scaling Messaging applications with OSGItm and AMQP 18: Putting your pipes ...
Task scheduling and virtual machine allocation policy in cloud computing environment
- Task scheduling - Database interaction using JDBC and Hibernate - Programmatic and declarative transaction management - Spring Web MVC - Developing RESTful Web Services using Spring - Spring ...
In order to effectively utilize massive heterogeneous resources and provide transparent computing capability to upper applications, task scheduling as the key issue of pervasive computing system ...