- 9
- 0
- 约 63页
- 2016-09-20 发布于浙江
- 举报
SUNWAH 2.7小结 Spring框架的核心是Spring容器。Spring提供了多种实现容器的方法,这些方法可以归纳为两类:BeanFactory是最简单的容器,它提供了基本的DI和Bean装配服务。如果需要用到更高级的框架服务,就需要使用Spring的ApplicationContext。 在本课中,我们介绍了如何将Bean与Spring容器装配在一起。通常,在Spring容器中使用XML来执行装配。这个XML文件包括了帮助容器执行DI的信息,以便Bean能够与其所依赖的其他Bean相关联。 * SUNWAH 使用以下代码来装载Spring应用上下文: ApplicationContext ctx = new ClassPathXmlApplicationContext( spring-di.xml); // 默认属性值 Performer juggler = (Performer) ctx.getBean(juggler); juggler.perform(); SUNWAH 2.2.2通过构造函数注入 注入基本类型的值: bean id=juggler1 class=com.sunwah.training.spring.di.Juggler constructor-arg value=6 / /bean 注入其他对象 SUNWAH
您可能关注的文档
- “大手拉小手,共筑祖国新未来”社会实践报告.docx
- “大手拉小手,共筑祖国新未来”实践报告.doc
- 《Database System Concepts Course Introduction》ch01.ppt
- 《Database System Concepts Course Introduction》ch02.ppt
- 《Database System Concepts Course Introduction》ch03.ppt
- 《Database System Concepts Course Introduction》ch04.ppt
- 《Database System Concepts Course Introduction》ch06.ppt
- 《Database System Concepts Course Introduction》ch07.ppt
- 《Database System Concepts Course Introduction》ch12.ppt
- 《Database System Concepts Course Introduction》ch13.ppt
- 《Struts2与控制器Action》T9.ppt
- 《Struts2与控制器Action》T10.ppt
- 《Struts2与控制器Action》T11.ppt
- 《Struts2与控制器Action》T12.pptx
- 《Struts2与控制器Action》专题5案例2.ppt
- 《Struts2与控制器Action》专题五案例一.ppt
- 《Summary of the course教学课件》ch02-li.ppt
- 《Summary of the course教学课件》ch03-li.ppt
- 《Summary of the course教学课件》ch03-li2.ppt
- 《Summary of the course教学课件》ch04-li.ppt
原创力文档

文档评论(0)