Dependency injection (DI) lets application components receive the objects they need instead of constructing and managing those objects themselves. In Spring, the application context acts as a container: it creates components called beans, manages their lifecycles, and wires them together into a working application. section 1.1
A typical Spring dependency relationship works like this:
- Define components such as an inventory service and a product service. section 1.1
- Declare that the product service depends on the inventory service. section 1.1
- Let the Spring application context create both beans and provide the inventory service through a constructor argument or property accessor. section 1.1
Wiring services
An inventory service fetches inventory levels, while a product service supplies product information. Because complete product information requires inventory data, Spring constructs the product service with the inventory service it manages. The same relationship can be expressed with XML bean definitions or Java configuration using @Configuration and @Bean methods. section 1.1
Figure 1.1 Application components are managed and injected into each other by the Spring application context.
The relationship diagram shows the Spring application context managing application components and injecting them into one another. section 1.1




















