扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!
1. 定时任务实现方式
定时任务实现方式:
定时任务执行方式:
2. 创建定时任务
package com.autonavi.task.test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import com.autonavi.task.ScheduledTasks; @Component public class ScheduledTest { private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class); @Scheduled(cron="0 0/2 * * * ?") public void executeFileDownLoadTask() { // 间隔2分钟,执行任务 Thread current = Thread.currentThread(); System.out.println("定时任务1:"+current.getId()); logger.info("ScheduledTest.executeFileDownLoadTask 定时任务1:"+current.getId()+ ",name:"+current.getName()); } }
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流