spring task使用方法

来源:互联网 发布:淘宝充值的钱可以退吗 编辑:程序博客网 时间:2024/06/15 13:10
spring task 配置


1.引入名称空间
xmlns:task="http://www.springframework.org/schema/task"


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


2.<!--开启这个配置,spring才能识别@Scheduled注解,spring task配置
    <task:annotation-driven scheduler="qbScheduler" mode="proxy"/>
    <task:scheduler id="qbScheduler" pool-size="10"/>


    <task:scheduled-tasks scheduler="qbScheduler">
        <task:scheduled ref="remoteScheduleController" method="timeTask" cron="0/1 * * * * ?"/>
    </task:scheduled-tasks>
     -->
其他配置固定,要做的就是配置作业类和目标方法
3.在定时方法上使用@Schedule(cron="")注解
原创粉丝点击