本篇知識點包括@Scheduled創建定時任務、@Async實現異步調用、 SpringBoot整合攔截器、多種發佈打包方式等。
12.1 使用@Scheduled創建定時任務
在Spring Boot的主類(啓動類)中加入@EnableScheduling註解,啓用定時任務的配置。@Scheduled支持cron表達式。
創建如下類,啓動應用。
import org.springframework.scheduling.annotation.Scheduled
本篇知識點包括@Scheduled創建定時任務、@Async實現異步調用、 SpringBoot整合攔截器、多種發佈打包方式等。
在Spring Boot的主類(啓動類)中加入@EnableScheduling註解,啓用定時任務的配置。@Scheduled支持cron表達式。
創建如下類,啓動應用。
import org.springframework.scheduling.annotation.Scheduled