1. 程式人生 > >spring @Scheduled 讀取配置檔案

spring @Scheduled 讀取配置檔案

先看效果:

操作很簡單:

在類上加一個註解:

@PropertySource(value = "classpath:application.yml")

在配置檔案裡是這樣配置的:

#定時任務執行時間配置 cron.msg: 0/10 * * * * ?

這樣配置是不行的:

cron:

  msg: 0/10 * * * * ?