In Springs latest version, we can autowire a bean using annotation as @Autowired
. This will autowire the bean using its type(or constructor, if applied on it).
Is there any way I can use the @Autowired
annotation based on the bean name which we were doing without annotation in Spring's XML file as autowire="byName"?
You can use:
@Autowired
@Qualifier("beanname")
According to the @Qualifier javadoc
This annotation may be used on a field or parameter as a qualifier for candidate beans when autowiring