• zhouwei's avatar
    init · bc7389af
    zhouwei authored
    bc7389af
ScheduledTasksService.java 811 Bytes
package com.nanyan.securitylink.schedule;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Service
@EnableScheduling
public class ScheduledTasksService {
    private final TaskScheduler taskScheduler;

    @Autowired
    RefreshConfigSync refreshConfigSync;

    public ScheduledTasksService(TaskScheduler taskScheduler) {
        this.taskScheduler = taskScheduler;
    }

    @PostConstruct
    public void scheduleTask() {

        //定时刷新配置
        taskScheduler.scheduleWithFixedDelay(() -> {
            refreshConfigSync.autoRefreshConfig();
        }, 60000);
    }
}