java-定时任务



import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Slf4j
@Configuration
@EnableScheduling
public class ScheduleTask {
@Resource
NewJiraController newJiraController;
@Scheduled(cron = "0 30 19 * * ?")
public void configureTasks() throws Exception {
System.err.println("执行静态定时任务时间: " + LocalDateTime.now());
newJiraController.batchSendPopo();
}
@Bean
public TaskScheduler taskScheduler() {
return new ConcurrentTaskScheduler();
}
}
posted @ 2021-04-06 14:38  小叶子leavescy  阅读(83)  评论(0编辑  收藏  举报