ApplicationContext和BeanFactory都是用于加载bean,但是ApplicationContext功能包含BeanFactory的所有功能。
一、加载配置
ApplicationContext sc=new ClassPathXmlApplicationContext("beans.xml");public ClassPathXmlApplicationContext(String configLocation) throws BeansException { this(new String[]{configLocation}, true, (ApplicationContext)null); }public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, @Nullable ApplicationContext parent) throws BeansException { super(parent); this.setConfigLocations(configLocations); if (refresh) { this.refresh(); } }
由源码可以知道,ClassPathXmlApplicationContext支持传入配置文件路径为数组格式,解析及扩展功能则由refresh方法实现
1、设置路径
<