Use this annotation in the bean implementation class
to make base interfaces of the bean be ignored from default
Spring autowiring.
Let's consider an example:
IBase
/ \
BaseImpl \
IChild
\
MegaImpl
Here IBase and IChild are interface, BaseImpl and MegaImpl are
implementation classes. Once you register BaseImpl and MegaImpl
as Spring beans you need to make either BaseImpl or MegaImpl
as
autowire-candidate='false'
We are likely to make Spring autowire BaseImpl to all
dependencies that require IBase and to autowire MegaImpl to all
dependencies that require IChild. This would simplify runtime dependencies
of the application
Sill, the only possible solution with
autowire-candidate='false' is to
make Spring autowire MegaImpl for all IChild and IBase dependencies.
It is also possible to use
primary='true' in BaseImpl declaration, in
order to implement right behaviour, but this approach does not scale
to the case you need to have more than 2 bean implementations
(i.e. we have MegaMegaImpl and IChildChild)
To use the annotation you need to add it to MegaImpl to declare
it should not be autowired for IBase interface dependency.
For more details on Spring see
the doc