路泰机电科技体检——数据平台后端
赵文轩
2024-06-04 68993f38cca7e67478f8462c36233d12299b4fbb
定时任务类
1个文件已添加
33 ■■■■■ 已修改文件
src/main/java/com/example/scheudleds/DictSync.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/scheudleds/DictSync.java
New file
@@ -0,0 +1,33 @@
package com.example.scheudleds;
import com.example.utils.DictionaryUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.IOException;
@Slf4j
@Component
@EnableScheduling
public class DictSync {
    @Autowired
    private DictionaryUtil dictionaryUtil;
    /**
     * 字典同步
     */
    @Scheduled(cron = "0 0 22 * * ? ")
    public void execDict(){
        try {
            dictionaryUtil.exec1();
        } catch (IOException e) {
            log.error("定时任务异常");
            e.printStackTrace();
        }
    }
}