springmvc 配置定时任务,cron表达式 您所在的位置:网站首页 springmvc实现定时任务 springmvc 配置定时任务,cron表达式

springmvc 配置定时任务,cron表达式

#springmvc 配置定时任务,cron表达式| 来源: 网络整理| 查看: 265

   xmlns:task="http://www.springframework.org/schema/task"     http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd           package com.jdck.task.service.impl; import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import com.jdck.task.service.CustTaskService; import com.jdck.task.service.TgJobLogsService; @Component public class TaskManagerExecute { private static final Log logger = LogFactory.getLog(TaskManagerExecute.class); @Resource private CustTaskService custTaskService; @Resource private TgJobLogsService jobLogsService; //@Scheduled(cron = "0/120 * * * * ? ") // 间隔30秒执行 @Scheduled(cron= "0 0 1,3 * * ?") // 每天凌晨1点,3点 public void test() { custTaskService.updateLoadBatch(); } @Scheduled(cron="0 0 1 4 * ?")// 每月1号的凌晨4点执行 //@Scheduled(cron = "0/120 * * * * ? ") public void executeInvtmstTask(){ jobLogsService.updateInvtmstPrice(); } @Scheduled(cron="0 0 1 6 * ?")// 每月1号的凌晨6点分执行 //@Scheduled(cron = "0/480 * * * * ? ") public void executeMaterTask(){ jobLogsService.updateMaterialPrice(); } }

    

 

 

1.记录下,今天搞了几个cron表达式,但是不怎么理想,网上也说的·一通!

感觉·自己·都·是依葫芦画瓢。

@Scheduled(cron="0 0 1 6 * ?")// 每月1号的凌晨6点分执行

 

@Scheduled(cron="0 0 1 4 * ?")// 每月1号的凌晨4点执行

 

@Scheduled(cron = "0/120 * * * * ? ") // 间隔120秒执行

@Scheduled(cron= "0 0 1,3 * * ?") // 每天凌晨1点,3点



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有