I am trying to understand the various Spring bean configurations, and at the outset, trying the traditional XML way.
Now I came to know for dependency injection,the "basic" methods are setter
injection and constructor
injection.
Thus far, good.
I also came to know that one more method which Spring provided is by Autowire
. In Autowire
we have many options, like: byType
, byName
, constructor
.
Now when I dig more about Autowire
option , it seems that for byType
and byName
to work there needs to have setter
method to be present while for Autowire
by constructor
there should be matching constructor.
Is this correct?
Now, if Autowire
internally uses constructor or setter, then why do we have this option present at all?
Can anyone help me understand this?