一、简单了解
二、AnnotationConfigWebApplicationContext
三、ClassPathXmlApplicationContext
四 分析
1、ResourceLoader代表了加载资源的一种方式,正是策略模式的实现。
2、构造方法
/**
* Create a new ClassPathXmlApplicationContext with the given parent,
* loading the definitions from the given XML files.
*
* @param configLocations array of resource locations
* @param refresh whether to automatically refresh the context,
* loading all bean definitions and creating all singletons.
* Alternatively, call refresh manually after further configuring the context.
* @param parent the parent context
* @throws BeansException if context creation failed
* @see #refresh()
*/
public ClassPathXmlApplicationContext(
String[] configLocations, boolean refresh, @Nullable ApplicationContext parent)
throws BeansException {
super(parent);
setConfigLocations(configLocations);
// 默认值为true 需要去 ClassPathXmlApplicationContext 类下查看
if (refresh) {
refresh();
}
}