![](https://csdnimg.cn/release/download_crawler_static/88694534/bg6.jpg)
从表面上看,application context 如同 bean factory 一样具有 bean 定义、bean 关联
关系的设置,根据请求分发 bean 的功能。但 application context 在此基础上还提供了
其他的功能。
1. 提供了支持国际化的文本消息
2. 统一的资源文件读取方式
3. 已在监听器中注册的 bean 的事件
以下是三种较常见的 ApplicationContext 实现方式:
1、ClassPathXmlApplicationContext:从 classpath 的 XML 配置文件中读取上下文,
并生成上下文定义。应用程序上下文从程序环境变量中取得。
ApplicationContext context = new ClassPathXmlApplicationContext(“bean.xml”);
2、FileSystemXmlApplicationContext :由文件系统中的 XML 配置文件读取上下文。
ApplicationContext context = new FileSystemXmlApplicationContext(“bean.xml”);
3、XmlWebApplicationContext:由 Web 应用的 XML 文件读取上下文。
6、Spring 有几种配置方式?
将 Spring 配置到应用开发中有以下三种方式:
1. 基于 XML 的配置
2. 基于注解的配置
3. 基于 Java 的配置