Autowiring By Name
Learn about the autowiring by name and see which approach has higher priority, by name or by type.
We'll cover the following...
Autowiring by name in Spring
In the last lesson, we looked at the autowiring by type approach where priority was given to the collaborative filter using the @Primary
annotation.
Another approach is autowiring by name where we specify the bean that is to be used by name. In this approach, while creating an object, the dependency is injected by matching the name of the reference variable to the bean name. The developer has to ensure that the variable name is the same as its bean name.