這是一個由simviso團隊所組織進行的基於Spring Framework 5.2.2版本基礎文檔翻譯。若是想要深刻討論,可掃描下方二維碼,加入官方羣和知秋的知識星球,免費給你們分享相關知識。web
因爲專業文檔翻譯難度比較大,咱們內部本着翻譯質量,也有一系列的規範,也因這些規範,消耗的時間更多,同時咱們本身時間也是有限的,做爲公益組織,當下也沒什麼收益,都是小夥伴天天晚上熬夜在作事情,請勿催更,望理解。
spring
知秋-掘金博客編程
https://juejin.im/user/59c764...app
虛生花-掘金博客框架
https://juejin.im/user/5c52b6...ide
This part of the reference documentation covers all the technologies that are absolutely integral to the Spring Framework.函數
參考文檔的這一部分涵蓋了Spring框架中全部必不可少的技術。ui
Foremost amongst these is the Spring Framework’s Inversion of Control (IoC) container. A thorough treatment of the Spring Framework’s IoC container is closely followed by comprehensive coverage of Spring’s Aspect-Oriented Programming (AOP) technologies. The Spring Framework has its own AOP framework, which is conceptually easy to understand and which successfully addresses the 80% sweet spot of AOP requirements in Java enterprise programming.this
其中最重要的就是Spring框架中的IoC容器。當對Spring IoC容器充分理解後,緊隨其來的就是對Spring AOP(面向切面編程)相關的全面介紹。Spring框架擁有它本身的AOP框架,該框架從概念上易於理解,它成功解決了Java企業編程中80%AOP需求相關痛點。spa
Coverage of Spring’s integration with AspectJ (currently the richest — in terms of features — and certainly most mature AOP implementation in the Java enterprise space) is also provided.
其中也涵蓋了Spring與AspectJ的集成(就功能而言,目前它是最豐富也是Java企業領域中最成熟的AOP實現)。
This chapter covers Spring’s Inversion of Control (IoC) container.
本章節涵蓋了Spring IoC容器相關內容。
This chapter covers the Spring Framework implementation of the Inversion of Control (IoC) 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) 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.
本章節涵蓋了Spring框架對於控制反轉(IoC)原理的實現。IoC也被稱爲依賴注入(DI) 。在此過程當中,對象只能經過構造函數參數,工廠方法的參數來定義其依賴項(即與之一塊兒使用的其餘對象),或者在經過構造器構造或從工廠方法返回獲得對象實例以後,在對象實例上對其屬性進行設置。而後,容器在建立bean時注入那些依賴項。此過程從本質上來說是經過使用類的直接構造或者例如服務定位模式之類的機制,從根本上反轉了bean自身對它依賴項的定位(知秋注:和其餘bean創建依賴聯繫)或實例化(所以稱爲控制反轉)。
The org.springframework.beans
and org.springframework.context
packages are the basis for Spring Framework’s IoC container. The BeanFactory
interface provides an advanced configuration mechanism capable of managing any type of object. ApplicationContext
is a sub-interface of BeanFactory
. It adds:
WebApplicationContext
for use in web applications.org.springframework.beans
和 org.springframework.context
兩個包是Spring框架中IoC容器的基礎。BeanFactory
接口提供了一種可以管理任何類型對象的高級配置機制。ApplicationContext
是 BeanFactory
的子接口,它添加了如下特性:
WebApplicationContext
In short, the BeanFactory
provides the configuration framework and basic functionality, and the ApplicationContext
adds more enterprise-specific functionality. The ApplicationContext
is a complete superset of the BeanFactory
and is used exclusively in this chapter in descriptions of Spring’s IoC container. For more information on using the BeanFactory
instead of the ApplicationContext,
see [beans-beanfactory].
簡單來講,BeanFactory
提供了配置框架以及基礎功能,而 ApplicationContext
添加了更多企業特定的功能。ApplicationContext
是 BeanFactory
的一個完整超集,它在本章中只用來描述Spring IoC容器。若是想了解更多 BeanFactory
使用上的信息而不是 ApplicationContext
的話,請查看 [beans-beanfactory] 這一章節。
In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. Otherwise, a bean is simply one of many objects in your application. Beans, and the dependencies among them, are reflected in the configuration metadata used by a container.
在Spring中,構成你應用程序主幹並經過Spring IoC容器進行管理的對象被稱爲bean。bean是一個由Spring IoC容器實例化,組裝並管理的一個對象。不然的話,bean只是你應用中衆多對象中的一個而已。Bean及其之間的依賴關係都反映在容器使用的配置元數據中。