package com.huihe.exam;
import com.huihe.exam.mapper.ScheduleMapper;
import com.huihe.exam.task.LoadOrgsTask;
import com.huihe.exam.task.SchedulerTask;
import com.huihe.exam.task.TaskAdmin;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.List;
import java.util.TimeZone;
@SpringBootApplication
@MapperScan("com.huihe.exam.mapper")
@EnableScheduling
@EnableAsync
public class ServiceExamApplication {
public static ApplicationContext applicationContext;
private static final Logger LOG = LoggerFactory.getLogger(ServiceExamApplication.class);
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(ServiceExamApplication.class, args);
ServiceExamApplication.applicationContext = context;
LOG.info("设置时区为东八区");
TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
TimeZone.setDefault(timeZone);
LOG.info("处理执行中的定时任务");
ScheduleMapper scheduleMapper = context.getBean(ScheduleMapper.class);
List<SchedulerTask> runningTaskList = scheduleMapper.getRunningTask();
TaskAdmin taskAdmin = context.getBean(TaskAdmin.class);
taskAdmin.handleTasks(runningTaskList);
LOG.info("加载机构和电话号码信息");
LoadOrgsTask task = context.getBean(LoadOrgsTask.class);
task.loadOrgInfo();
LOG.info("考试服务启动...");
}
}
打开App,阅读手记