Series 2 DI spring

concept

Dependency Injection: Dependency Injection. It is a concrete implementation framework core ioc spring of.
Our program in the preparation, by inversion of control, to create objects to the spring, but the code does not depend on circumstances that can not happen.
ioc decoupling only reduce their dependency, but not eliminated. For example: Our business layer will call the method persistence layer.
This dependency that the business layer and persistence layer, after using the spring, let the spring to maintain.
Simply put, it is to wait for the incoming object persistence layer framework to the business layer, instead of our own to get

Constructor injection

Is the constructor of the class, to the member variable. Note that, by assignment operation arranged by the spring frame is injected.

set injection method

P-namespace injection (nature or set method)

Injecting a collection of attributes

Guess you like

Origin www.cnblogs.com/mantishell/p/12555971.html