springboot初始化例子
/**
* spring boot初始化
*
* @author
*
*/
@Component
@Order(1) // 通过order值的大小来决定启动的顺序
@Slf4j
public class InitSpringBoot implements CommandLineRunner {
private SysBackupScheduledMapper sysBackupScheduledMapper = ManageSpringBeans
.getBean(SysBackupScheduledMapper.class);
private ScheduledMapper scheduledMapper = ManageSpringBeans.getBean(ScheduledMapper.class);
private LdapMapper ldapMapper = ManageSpringBeans.getBean(LdapMapper.class);
// 定时器工具类
private ScheduleUtil scheduleUtil = ManageSpringBeans.getBean(ScheduleUtil.class);
/**
* 系统备份定时器初始化
*/
private void sysBackupScheduledInit() {
SysBackupScheduled sysBackupScheduledDb = sysBackupScheduledMapper.getSysBackupScheduled();
Optional<SysBackupScheduled> sysBackupScheduledDbOpt = Optional.ofNullable(sysBackupScheduledDb);
Boolean isOpen = sysBackupScheduledDbOpt.map(s -> s.getIsOpen()).orElse(false);