Article Directory
I. Introduction dependency injection
Dependency injection (Dependency Injection, abbreviated DI) is embodied in the Spring Framework IoC core.
Dependency injection is the most common way to control inversion by inversion of control can reduce the degree of coupling between the computer code.
By inversion of control, when the object was created by a 调控系统内所有对象的外界实体
will which it depends object passed to it. It can be said, it is injected into the subject dependency.
Management II dependencies
Management Spring dependencies are to be maintained.
In the current class need to use objects of other classes provided by Spring to us, we just need to explain in the configuration file.
这种依赖关系的维护就叫做依赖注入
.
Third, the data can be injected
-
Basic types and String.
-
Other bean types (in the configuration file or the configuration notes had bean).
-
Complex Type / collection type.
Four three dependency injection
- Use constructor injection
- Use the injection method set
- Injection using annotations