自啟動(初始化)
1 CommandLineRunner 接口
用作将其加入spring容器中時執行其run方法。多個CommandLineRunner可以被同時執行在同一個spring上下文中并且執行順序是以order注解的參數順序一緻。
實作CommandLineRunner 接口,重寫run方法。
代碼:
@Component
@Configuration
public class ExchangeInitRunnable implements CommandLineRunner {
private static final Logger LOGGER = LoggerFactory.getLogger(ExchangeInitRunnable.class);
@Override
public void run(String… strings) throws Exception {
RealTime.init();
}