- BeanFactory接口,在org.springframework.beans.factory包下,提供了IoC容器的最基本功能。
- ApplicationContext接口,在org.springframework.context包下,继承BeanFactory,增加更多企业级支持。
- XmlBeanFactory类,BeanFactory实现,可以从classpath或文件系统等获取资源。
- ClassPathXmlApplicationContext类,ApplicationContext实现,从classpath获取配置文件。
- FileSystemXmlApplicationContext类,ApplicationContext实现,从文件系统获取配置文件。
- 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
- Bean Reader、BeanDefinition?
(3)spring获取资源的类及获取bean的方法
最新推荐文章于 2024-06-24 08:51:22 发布