Application.java 1.58 KB
package vion;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import vion.controller.UserController;

import java.util.concurrent.CountDownLatch;


@SpringBootApplication
@EnableScheduling
public class Application implements CommandLineRunner {
    public static void main(String[] args) {
        try {
            SpringApplication.run(Application.class, args);
            new CountDownLatch(1).await();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Autowired
    private UserController userController;

    private final static Logger logger = LoggerFactory.getLogger(Application.class);

    //@Scheduled(fixedDelay=1000*60*10,initialDelay=1000)
    @Scheduled(cron="${third.run.cron:0 0 2 * * ?}")
    public void startJob(){
        try {
            logger.info("启动");
            //定时获取钉钉用户列表
            userController.getDingUserList();
            //USERNAME_MAP

            logger.info("启动完成");
        } catch (Exception e) {
            e.printStackTrace();
//            System.exit(-1);
        }
    }

    @Override
    public void run(String... args) throws Exception {

    }
}