如何理解Spring Framework的控制反轉?

時間 2021-05-30 21:36:55

1樓:Andy

控制反轉,是web應用伺服器的概念。

web應用伺服器,使用者操作客戶端,或者瀏覽器訪問的路徑,最終目標都是訪應用的乙個個物件。

如果使用者每訪問一次,就生成乙個物件,那電腦資源就被佔據太多了。所以,要在應用才啟動時,就把使用者訪問的物件生成成功,這樣,使用者訪問相同路徑中的物件,基本都是第一次生成的物件。

也就是說,以前,物件由虛擬機器控制,使用者訪問,虛擬機器生成乙個,現在,物件由AOP容器控制,應用才建立,AOP容器就建立好了。

對物件的控制,從虛擬機器手裡,重新拿到了應用手裡。

2樓:huapro

7.1 Introduction to the Spring IoC container and beans

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.

官方文件多看看https://

docs.spring.io/spring/docs/4.

3.6.RELEASE/spring-framework-reference/pdf/spring-framework-reference.pdf

理解應該如何理解?

CHON 如果兩種 理解 在同一平面,在邏輯上,這是乙個關於表意的 自指性 問題,轉化成問題 我能認識自己嗎 但如果兩種 理解 不在同一平面,一種理解是相對高位,一種理解是相對低位,同樣也可以看作是函式的公升降階問題 那麼跳出問題本身,我們是否真的需要 理解 這種概念?以及在各種語境中 理解 的各自...

如何理解「同情之理解」這句話?

了解之同情 這是陳寅恪在為馮友蘭 中國哲學史 上冊所寫的審查報告中的一句話,原文如下 了解之同情 是針對古代學說而言的,有兩個含義,一是 了解 二是 同情 了解 是屬於科學認知的範疇。我們古人雖然有很多共通之處,但畢竟世殊事異,古今的政治制度,社會風氣,思想觀念,乃至自然環境,都和現在有很大的差距,...

如何理解中庸

i007 沒啥,孔子是可愛的,千萬別太較真,太認真也不行,差不多就行了。中心,如心,忠恕。鼓勵活出你自己,但是永遠允許你不做英雄。2019.04.29.周一。 史思明 聖人說極高明而道中庸。孔子都說中行很難啊。退而求其次,他也只能選狂狷之士了。我個人的理解,比如乙個仁人志士勇敢赴死。就說譚嗣同。我們...