Dependency injection (DI) is one implementation of IoC. In interaction with other modules, the program operates using high-level abstractions, while the concrete implementation is provided by the framework.
The usual implementation of DI involves the framework instantiating all services and storing them in an IoC container. A special entity, the Service Locator, is responsible for finding matches between implementations and abstractions and injecting them.
Spring consists of a large set of various libraries. DI is implemented by one of the main libraries – Spring IoC.
Business logic entities in Spring, similar to JavaEE, are called beans. Beans are declared in various ways, most of which originate from the concept of
Configuration
. The container for beans is represented by ApplicationContext
. To delegate the initialization of a dependency to the context, it is marked with the @Autowired
annotation.