Spring(3)

一、Spring容器

  Spring 提供了两种类型的IOC容器(后面还会讲到AOP容器)

  (1)BeanFactory:IOC容器的基本实现,是Spring框架的基础设施,面向Spring的本身

  (2)ApplicationContext面向使用Spring框架的开发者,几乎所有的应用场合都使用它,而非底层的BeanFactory,ConfigurableApplicationContext是ApplicationContext的子接口,扩展于ApplicationContext,新增两个主要方法,refresh()和close(),让ApplicationContext具有启动刷新和关闭上下文的作用。Spring容器在初始化上下文的时候就实例化所有的单例的bean

    其中,ApplicationContext子接口ConfigurableApplicationContext的主要实现类:

    --ClassPathXmlApplicationContext,是从类路径下加载XML配置文件

    --FileSystemXmlApplicationContext,是从文件路径下加载XML配置文件

    --WebApplicationContext是专门为WEB应用而准备的,它允许从相对于web的根目录的路径中完成初始化的操作

   接口和实现类的关系图如图所示:

   

  

  

  

  

  

原文地址:https://www.cnblogs.com/caoyang-q/p/5302850.html