CommandLineRunner
CommandLineRunner的实现类可以在SpringBoot启动时启动(通过@Order可以控制执行顺序)
例:
@Slf4j
@Component
@Order(1)
public class StatisticReportPoolRunner implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
        log.info("线程池启动");
        StatisticReportPool runnable = ApplicationContextProvider.getBean(Constants.STATISTIC_REPORT_POOL_TASK_BEAN, StatisticReportPool.class);
        new Thread(runnable).start();
    }
}
 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号