当前位置:网站首页>@Scheduled scheduled task details
@Scheduled scheduled task details
2022-07-21 20:07:00 【adadapter】
Spring Of @Scheduled Annotations can handle some simple scheduled tasks , Such as statistical quantity 、 Database backup, etc . The configuration contents and actual examples are as follows :
rely on
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.0</version>
</dependency>
@EnableScheduling annotation
Add... In the startup class @EnableScheduling Note the timing task
@SpringBootApplication
@EnableScheduling
public class ScheduledApplication {
public static void main(String[] args) {
SpringApplication.run(ScheduledApplication.class,args);
}
}
Configure scheduled tasks
@Component
public class MySchedule {
@Scheduled(fixedDelay = 1000)
public void fixedDelay(){
System.out.println("fixedDelay:"+new Date());
}
@Scheduled(fixedRate = 2000)
public void fixedRate(){
System.out.println("fixedRate:"+new Date());
}
@Scheduled(initialDelay = 1000, fixedRate = 2000)
public void initialDelay(){
System.out.println("initialDelay:"+new Date());
}
@Scheduled(cron = "0 * * * * ?")
public void cron(){
System.out.println("cron:"+new Date());
}
}
@Scheduled Start a timed task ,fixedDelay =1000, Indicates that the execution of the current task ends 1 Start another task in seconds ;
fixedRate=2000 Indicates that the current task starts execution 2 Start another scheduled task in seconds ,initialDelay=1000 Indicates the delay time of the first execution
Running results ( Console )
边栏推荐
- 支持数据 + 代码生成的开发工具,yyds
- MySQL DCL (data control language)
- Gradually understand the deep belief network
- 《构建之法》笔记---第六章 敏捷流程
- Ibm3650m4 physical machine installation esxi7.0
- 10 lines of code to realize wechat applet payment function, and use applet cloud development to realize applet payment function (including source code
- C -- compilation preprocessing
- One more blank page when printing the Jim building block report - problem solving
- MySQL DQL (data query language) - common functions
- 866. Trial division to determine prime numbers
猜你喜欢
As editor sets the indent position of the code on the right side of fluent development
Array and object copy of ES6
FL Studio 20.9 Chinese patch package for fruit composition software
Fluent customizes form and encapsulates form components
FL Studio 20.9水果编曲软件中文汉化补丁包
数据类型Map判空 、空字符串、空key值等各种判断方法,全网最详细
3-6月面经总结,200多页真题笔记和详解(含核心考点及6家大厂)
判断“String[]”数组中是否有存在重复的值,利用hashSet特性排查
Pychart creates SQLite database
Getting started with the gradle project construction tool
随机推荐
Development tools supporting data + code generation, yyds
2022.7.18DAY609
Wechat public number Development Access, Application for Test number for Local Development Using Wechat public Platform
Let you say goodbye to the project maintenance mode of 996
ImportError: DLL load failed while importing win32gui: 找不到指定的模块。
629. K inverse pairs array
LeetCode 76. 最小覆盖子串-滑动窗口法
Unity ECS 测试Demo
Jenkins插件开发——提供对外访问接口
Solutions: connections could not be acquired from the underlying database!
flutter自定义form表单,封装form表单组件
2022.7.21DAY611
Okaleido tiger NFT is about to log in to binance NFT platform, and the future market continues to be optimistic
(4) Transactions
解决:Connections could not be acquired from the underlying database!
Flutter obtains longitude and latitude through geolocator positioning plug-in and calls Gaode peripheral information interface
869. 试除法求约数
微信小程序支付
MySQL DQL (data query language) - common keywords
Bluetooth intelligent nutrition electronic scale solution