@Scheduled 使用問題

使用@Scheduled時,需要啓動task
啓動方式:
1.使用xml方式,在spring配置文件中添加

<task:annotation-driven>

2.使用spring configuration方式,在配置類即@Configuration下加上@EnableScheduling

@Configuration
@EnableScheduling
@PropertySource({"classpath:application.properties", "classpath:config.properties"})
@EnableTransactionManagement(proxyTargetClass = true)
public class AppConfig {
}

官方文檔:官方文檔地址

發佈了35 篇原創文章 · 獲贊 14 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章