SpringBoot是如何动起来的?
程序入口
1 | SpringApplication.run(BeautyApplication. class , args); |
执行此方法来加载整个SpringBoot的环境。
1. 从哪儿开始?
SpringApplication.java /** * Run the Spring application, creating and refreshing a new * {@link ApplicationContext}. * @param args the application arguments (usually passed from a Java main method) * @return a running {@link ApplicationContext} */ public ConfigurableApplicationContext run(String... args) { //... }
调用SpringApplication.java 中的 run 方法,目的是加载Spring Application,同时返回 ApplicationContext。
2. 执行了什么?
2.1 计时
记录整个Spring Application的加载时间!
StopWatch stopWatch = new StopWatch(); stopWatch.start(); //