Dependency injection

To wire up dependencies, we can use these two annotations provided by Spring—the @Required annotation and the @Autowired annotation. We can apply the @Required annotation to setter methods and the @Autowired annotation to constructor, methods, as well as fields. 

To sum up, in Spring, there are three ways to inject dependencies:

  • Constructor-based injection
  • Setter-based/method-based injection
  • Field-based injection.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.22.164