(3)spring获取资源的类及获取bean的方法

  1. BeanFactory接口,在org.springframework.beans.factory包下,提供了IoC容器的最基本功能。
  2. ApplicationContext接口,在org.springframework.context包下,继承BeanFactory,增加更多企业级支持。(3)spring获取资源的类及获取bean的方法
  3. XmlBeanFactory类,BeanFactory实现,可以从classpath或文件系统等获取资源。(3)spring获取资源的类及获取bean的方法
  4.  ClassPathXmlApplicationContext类,ApplicationContext实现,从classpath获取配置文件。(3)spring获取资源的类及获取bean的方法
  5. FileSystemXmlApplicationContext类,ApplicationContext实现,从文件系统获取配置文件。(3)spring获取资源的类及获取bean的方法
  6. BeanFactory接口获取Bean的几个方法
    • <T> T     getBean(Class<T> requiredType) Return the bean instance that uniquely matches the given object type, if any.根据类型返回bean
    • Object     getBean(String name) Return an instance, which may be shared or independent, of the specified bean.根据名称返回bean,需要自己进行类型转化
    • <T> T     getBean(String name, Class<T> requiredType) Return an instance, which may be shared or independent, of the specified bean.根据名称和类型返回bean
  7. Bean Reader、BeanDefinition?