又到年关了,还有几天就是春节。趁最后还有些时间,复习一下Spring的官方文档。

写在前面的话:

Spring是我首次开始尝试通过官方文档来学习的框架(以前学习Struts和Hibernate都大多是视频或书籍为主,文档一带而过)。除了语言上的障碍以外更困难的地方是对新概念的理解,这些都是过了很久才逐渐体会。要说有什么经验的话,那就是对于不同的文档都似乎有它们自己的上下文语境。虽然不可否认外国人在文档统一性方面已经做的非常出色了,但只要还有那么一点点差异在语言的“阻拦”下依旧会让我觉得深奥。仅这一点来说看中文的书籍或视频讲解确实学的更快。这次跟着创作博客的节奏又大致浏览一遍,希望能有新的发现。

***************************以下是正文的部分***************************

一、Ioc和DI

(1)概念

This chapter covers the Spring Framework implementation of the Inversion of Control (IoC) [1] principle. IoC is also known as dependency injection (DI). It is a process whereby objects define their dependencies, that is, the other objects they work with, only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. The container then injects those dependencies when it creates the bean. This process is fundamentally the inverse, hence the name Inversion of Control (IoC), of the bean itself controlling the instantiation or location of its dependencies by using direct construction of classes, or a mechanism such as the Service Locator pattern.
Introduction to the Spring IoC container and beans

相关文章: