Skip to content

Commit 2438f15

Browse files
committed
添加了定时任务
1 parent 5860373 commit 2438f15

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.xiaour.spring.boot.task;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.scheduling.annotation.EnableScheduling;
5+
import org.springframework.scheduling.annotation.Scheduled;
6+
7+
@Configuration
8+
@EnableScheduling // 启用定时任务
9+
public class Task {
10+
11+
@Scheduled(cron="0 0/1 * * * ?")
12+
public void run(){
13+
System.out.println("定时任务执行");
14+
}
15+
}

SpringBootDemo/src/main/resources/application.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ logging:
4747
level:
4848
com.ibatis:DEBUG
4949
root:DEBUG
50+
51+
task:
52+
cron:0 0/1 * * * ?
5053

5154

0 commit comments

Comments
 (0)