CsdnSchedule.java 873 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11
package com.kwan.springbootkwan.schedule;


import com.kwan.springbootkwan.service.CsdnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Slf4j
12
@Component
13 14 15 16 17
public class CsdnSchedule {

    @Autowired
    private CsdnService csdnService;

18
    @Scheduled(cron = "0 0 8,10,12,14,16,18,20 * * ?")
19 20 21 22 23
    public void execute() {
        log.info("Scheduled task is running ... ...");
        csdnService.multiTriplet();
        log.info("Scheduled task is finish ... ...");
    }
24 25 26 27 28 29 30

    @Scheduled(cron = "0 0/30 * * * ?")
    public void executeMultiComment() {
        log.info("Scheduled task is running ... ...");
        csdnService.multiComment();
        log.info("Scheduled task is finish ... ...");
    }
31 32
}