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

   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

<!-- task任务扫描注解 -->
    <task:annotation-driven/>
    <context:component-scan base-package="com.jdck.task.service.impl"></context:component-scan>
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点

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值