- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 104字
- 2021-06-24 19:24:39
How to do it...
- Let's add an @EnableScheduling annotation to the BookPubApplication class, as follows:
@SpringBootApplication @EnableScheduling public class BookPubApplication {...}
- As a @Scheduled annotation can be placed only on methods without arguments, let's add a new run() method to the StartupRunner class and annotate it with the @Scheduled annotation, as shown in the following line:
@Scheduled(initialDelay = 1000, fixedRate = 10000) public void run() { logger.info("Number of books: " + bookRepository.count()); }
- Start the application by executing ./gradlew clean bootRun from the command line so as to observe the Number of books: 0 message that shows in the logs every 10 seconds.
推薦閱讀
- PyTorch深度學習實戰:從新手小白到數據科學家
- Learning Spring Boot
- 業務數據分析:五招破解業務難題
- 醫療大數據挖掘與可視化
- iOS and OS X Network Programming Cookbook
- 算法與數據中臺:基于Google、Facebook與微博實踐
- Sybase數據庫在UNIX、Windows上的實施和管理
- Dependency Injection with AngularJS
- 大數據Hadoop 3.X分布式處理實戰
- INSTANT Android Fragmentation Management How-to
- Doris實時數倉實戰
- Deep Learning with R for Beginners
- Configuration Management with Chef-Solo
- 數據時代的品牌智造
- Applying Math with Python