Spring Boot 配置文件加载源码分析

3月 1, 2018 |

源码位置:SpringApplication.doRun
步骤如下:

1、创建默认的Environment
2、将命令行参数添加到Environment
3、listeners.contextPrepared(context)
发送ApplicationEnvironmentPreparedEvent事件给ConfigFileApplicationListener,加载application.properties配置文件
4、listeners.contextLoaded(context)
发送ApplicationPreparedEvent事件给ConfigFileApplicationListener,添加调整PropertySource顺序的PostProcessor

Posted in: spring practise

Comments are closed.