有兩種方法:
第一種當然你可以把Scheduled寫到xml文件中進行配置。
第二種在你的類前面添加
此處講解第二種寫法
第二種在你的類前面添加
@PropertySource("classpath:root/test.props")
然后修改你的@Scheduled(cron="0/5 * * * * ? ") 為 @Scheduled(cron="${jobs.schedule}")
最后在配置文件 test.props中 添加 jobs.schedule = 0/5 * * * * ?
有兩種方法:
第一種當然你可以把Scheduled寫到xml文件中進行配置。
第二種在你的類前面添加
此處講解第二種寫法
第二種在你的類前面添加
@PropertySource("classpath:root/test.props")
然后修改你的@Scheduled(cron="0/5 * * * * ? ") 為 @Scheduled(cron="${jobs.schedule}")
最后在配置文件 test.props中 添加 jobs.schedule = 0/5 * * * * ?
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。