springboot整合定时任务task
- 在springboot启动类上开启定时任务开关@EnableScheduling
- 新建一个要执行的任务
@Scheduled(cron = "0/5 * * * * ?")
表示要执行的频率
@Scheduled(cron = "0/5 * * * * ?")
public void print(){
System.out.println("task>>>>>>>>>>>>>>>>>");
}
- application.yml 文件中可以配置相关属性 如(前缀、连接池大小等)
spring:
task:
scheduling:
thread-name-prefix: spring_task
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果

