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点