郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.gkhy.safePlatform.account.schedule;
 
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
@Component
@EnableScheduling
@ConditionalOnProperty(prefix = "threadPool.scheduling", name = "enabled", havingValue = "true")
public class TestScheduleJob {
 
    private int i = 0;
 
//    @Scheduled(cron = "0/5 * * * * ?") //每隔5s执行一次
    public void showTime(){
        System.out.println(new Date().toString());
        i++;
        if(i == 3){
            int a = this.i / 0;
        }
    }
}