The core principle of springIOC

What is a IOC:

1 What is dependence? A class (or objects a), and uses a class B (the object or b) the property / method A depends on B may be referred to
in the absence of a springIOC, attribute B is 2 when used in A / methods, we work to create a B object by new B () a call. The IOC appears that we do not need to manually
code to these new objects, but rather spring of IOC container will help us to achieve.
3 IOC (Inversion of Control) Inversion of Control: The so-called inversion of control, that is, the original objects we need to implement the code inside the creator
. Built-dependent code, reverse to the container to help achieve since it is handed over to the vessel to achieve, so inevitable we need to create a container, and a description of the need to let the
container know the relationship between the object and the object needs to be created. . This description is the most concrete manifestation of what we have seen profiles.
4 DI (Dependency Injection) DI: it refers to the object class is passively rely instead on their own initiative to find, in other words it
means the object is not to find a class which depends from the container, but when the container object is instantiated it depends on the class of the active injection to it.
5 the relationship between objects and object can be expressed by xml, properties files semantic profile. It describes the relationship between objects may be stored in a file classpath, filesystem, network resource or URL,
servletContext and so on.

The following may seem a little motion sickness, to see if the combination of source code will be more clear. The following are available as organize your thoughts

Two mentioned above to create and inject dependent objects, are achieved in the container, that spring is how to create the container?

spring IOC initialization container three

Positioning (positioning and scanning profile associated annotations) - loading (loading configuration information into memory) - registration (according to information loaded into the object initialization container IOC):
Here Insert Picture Description

Three springIOC timing diagrams

Here Insert Picture Description

Published 19 original articles · won praise 6 · views 10000 +

Guess you like

Origin blog.csdn.net/P502520/article/details/103859253