spring中beanfactory和applicationcontext创建bean的区别
来源:互联网 发布:南达科他级战列舰数据 编辑:程序博客网 时间:2024/05/17 06:51
l BeanFactory :这是一个工厂,用于生成任意bean。
采取延迟加载,第一次getBean时才会初始化Bean
l ApplicationContext:是BeanFactory的子接口,功能更强大。(国际化处理、事件传递、Bean自动装配、各种不同应用层的Context实现)。当配置文件被加载,就进行对象实例化。
ClassPathXmlApplicationContext用于加载classpath(类路径、src)下的xml
加载xml运行时位置 --> /WEB-INF/classes/...xml
FileSystemXmlApplicationContext 用于加载指定盘符下的xml
加载xml运行时位置 --> /WEB-INF/...xml
通过java webServletContext.getRealPath() 获得具体盘符
@Test
publicvoid demo02(){
//使用BeanFactory --第一次条用getBean实例化
String xmlPath = "com/itheima/b_di/beans.xml";
BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(xmlPath));
BookService bookService = (BookService) beanFactory.getBean("bookServiceId");
bookService.addBook();
}
- spring中beanfactory和applicationcontext创建bean的区别
- spring 中beanFactory和ApplicationContext的区别
- spring 中beanFactory和ApplicationContext的区别
- Spring中BeanFactory和ApplicationContext的区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别 .
- Spring中ApplicationContext和beanfactory区别
- 【转】Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- 各种return的情况下try catch finally的执行顺序
- 云计算概览
- 熵编码(entropy encoder)
- Revit开发之管段
- db_lmdb.hpp:15] Check failed: mdb_status
- spring中beanfactory和applicationcontext创建bean的区别
- mybatis中#{}和${}的区别与用法
- java多线程(十) 之 构建高效且可伸缩的结果缓存
- 一分钟解决Chrome浏览器主页被hao123、360和2345篡改简单有效方法
- The situation and future of 5G technology
- angularJs中ng-repeat实例
- Poj 1010
- 走进java_符号引用与直接引用
- Python如何使用装饰器(Decorator)修改yield function返回值