背景:
搞个定时任务,什么时候执行不确定,不想每次修改都改代码
只能把定时时间搞成动态的。。
1、application.properties配置文件配置定时表达式
job.corn = 0/5 0 * * * ?
目前五秒跑一次
2、@Scheduled(cron = "${job.corn}")
去配置文件值
package com.dj.internet.task.batch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import redis