Springboot創建定時任務(可配置)


@ApiModel("***定時任務")
@Component
@Configuration
@EnableScheduling
//@PropertySource("classpath:/***") // 可指定配置文件
public class MatchOpenCheckScheduledTask { private final Logger log = LoggerFactory.getLogger(this.getClass()); @Scheduled(cron = "${open-check.cron}") public void openCheckTask(){ log.info("執行‘自動匹配開通校驗’定時任務開始:" + FlowUtil.getCurrentDate("yyyy-MM-dd HH:mm:ss") ); long startTime = System.currentTimeMillis(); //獲取開始時間   /**********************************************************************************************/


  /**********************************************************************************************/

long endTime = System.currentTimeMillis(); //獲取結束時間 log.info("執行‘自動匹配開通校驗’定時任務結束:" + FlowUtil.getCurrentDate("yyyy-MM-dd HH:mm:ss") ); log.info("執行時間:"+(endTime - startTime)/1000+" 秒"); }

 

在線Cron表達式生成器

    https://cron.qqe2.com/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM