1. 程式人生 > >spring @Scheduled 定時任務

spring @Scheduled 定時任務

@Service
public class TimerTask{
	private static final Logger logger = LoggerFactory.getLogger(TimerTask.class);
    @Scheduled(cron="${push.task.cron}") //動態獲取配置檔案中 push.task.cron=0 59 16 30 10 ?
    public void index(){
        logger.info("==========定時任務執行中========");
    }
}

spring*.xml配置檔案新增 <task:annotation-driven />