June 2018
Intermediate to advanced
408 pages
11h 23m
English
The @Autowired annotation injects object dependency implicitly. We can use the @Autowired annotation on a constructor-setter-and field-based dependency pattern. The @Autowired annotation indicates that auto wiring should be performed for this bean.
Let's look at an example of using the @Autowired annotation on a constructor-based dependency:
public class BankingService { private CustomerService customerService; @Autowired public BankingService(CustomerService customerService) { this.customerService = customerService; } ......}
In the previous example, we have BankingService that has a dependency of CustomerService. Its constructor is annotated with @Autowired, indicating that Spring instantiates the BankingService ...
Read now
Unlock full access