天天看點

Spring task 定時任務模闆Spring task

Spring task

定時任務模闆

<task:scheduled-tasks scheduler="taskScheduler">
        <!-- 每半分鐘觸發任務 -->
        <task:scheduled ref="app" method="execute1" cron="30 * * * * ?"/>
        <!-- 每小時的10分30秒觸發任務 -->
        <task:scheduled ref="app" method="execute2" cron="30 10 * * * ?"/>
        <!-- 每天1點10分30秒觸發任務 -->
        <task:scheduled ref="app" method="execute3" cron="30 10 1 * * ?"/>
        <!-- 每月20号的1點10分30秒觸發任務 -->
        <task:scheduled ref="app" method="execute4" cron="30 10 1 20 * ?"/>
        <!-- 每年10月20号的1點10分30秒觸發任務 -->
        <task:scheduled ref="app" method="execute5" cron="30 10 1 20 10 ?"/>
        <!-- 每15秒、30秒、45秒時觸發任務 -->
        <task:scheduled ref="app" method="execute6" cron="15,30,45 * * * * ?"/>
        <!-- 15秒到45秒每隔1秒觸發任務 -->
        <task:scheduled ref="app" method="execute7" cron="15-45 * * * * ?"/>
        <!-- 每分鐘的每15秒時任務任務,每隔5秒觸發一次 -->
        <task:scheduled ref="app" method="execute8" cron="15/5 * * * * ?"/>
        <!-- 每分鐘的15到30秒之間開始觸發,每隔5秒觸發一次 -->
        <task:scheduled ref="app" method="execute9" cron="15-30/5 * * * * ?"/>
        <!-- 每小時的0分0秒開始觸發,每隔3分鐘觸發一次 -->
        <task:scheduled ref="app" method="execute10" cron="0 0/3 * * * ?"/>
        <!-- 星期一到星期五的10點15分0秒觸發任務 -->
        <task:scheduled ref="app" method="execute11" cron="0 15 10 ? * MON-FRI"/>
    </task:scheduled-tasks>