一、接口:org.springframework.context.ApplicationContextInitializer
1、接口实例加载过程
- 从项目的classPath路径下(包括依赖的jar)加载配置文件:META-INF/spring.factories
- 形成LinkedMultiValueMap,key:接口名 value:接口的实现类全路径
- 缓存至org.springframework.core.io.support.SpringFactoriesLoader的Map<ClassLoader, MultiValueMap<String, String>> cache = new ConcurrentReferenceHashMap<>();属性中
- 根据接口名获取实现类名字的集合,然后对集合名字进行实例化
- 将该类接口的实例设置到org.springframework.boot.SpringApplication的实例的List<ApplicationContextInitializer<?>> initializers 属性中
2、接口实现
3、接口作用
二、接口:org.springframework.context.ApplicationListener
1、接口实例加载过程
- 从项目的classPath路径下(包括依赖的jar)加载配置文件:META-INF/spring.factories
- 形成LinkedMultiValueMap,key:接口名 value:接口的实现类全路径
- 缓存至org.springframework.core.io.support.SpringFactoriesLoader的Map<ClassLoader, MultiValueMap<String, String>> cache = new ConcurrentReferenceHashMap<>();属性中
- 根据接口名获取实现类名字的集合,然后对集合名字进行实例化
- 将该类接口的实例设置到org.springframework.boot.SpringApplication的实例的List<ApplicationContextInitializer<?>> initializers 属性中
2、接口实现
3、接口作用