1、Spring的@Scheduled註解需要寫在實現上;
2、具體的cron表達式,可以用網站來生成:http://cron.qqe2.com/
3、定時器的任務方法不能有返回值(如果有返回值,spring初始化的時候會告訴你有個錯誤、需要設定一個proxytargetclass的某個值爲true );
4、實現類上要有組件的註解@Component;
5、使用Spring-boot需要在Application上加註解@EnableScheduling
1、Spring的@Scheduled註解需要寫在實現上;
2、具體的cron表達式,可以用網站來生成:http://cron.qqe2.com/
3、定時器的任務方法不能有返回值(如果有返回值,spring初始化的時候會告訴你有個錯誤、需要設定一個proxytargetclass的某個值爲true );
4、實現類上要有組件的註解@Component;
5、使用Spring-boot需要在Application上加註解@EnableScheduling