spring注解配置quartz

常规配置quartz可以参考我的另外一篇博文:http://www.cnblogs.com/yangzhilong/p/3349116.html

 

spring配置文件里增加:

命令空间:

http://www.springframework.org/schema/task   
http://www.springframework.org/schema/task/spring-task-4.0.xsd  

配置:

<task:annotation-driven/>  

当然这还需要扫描注解等常规配置。

 

java代码:

package com.test;
import org.springframework.scheduling.annotation.Scheduled;   
import org.springframework.stereotype.Component;

@Component  
public class TestJob {
    @Scheduled(fixedDelay = 1000) 
    public void test()
    {
        System.out.println("job 开始执行");
    } 
}
Scheduled类的可配置属性项:
Stringcron
A cron-like expression, extending the usual UN*X definition to include triggers on the second as well as minute, hour, day of month, month and day of week.
longfixedDelay
Execute the annotated method with a fixed period between the end of the last invocation and the start of the next.
StringfixedDelayString
Execute the annotated method with a fixed period between the end of the last invocation and the start of the next.
longfixedRate
Execute the annotated method with a fixed period between invocations.
StringfixedRateString
Execute the annotated method with a fixed period between invocations.
longinitialDelay
Number of milliseconds to delay before the first execution of a  fixedRate() or  fixedDelay() task.
StringinitialDelayString
Number of milliseconds to delay before the first execution of a  fixedRate() or  fixedDelay() task.
Stringzone
A time zone for which the cron expression will be resolved.

转载于:https://www.cnblogs.com/yangzhilong/p/3794864.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值