Let's say we have 2 implementations of an interface:
@Component
public class Toyota implements Car {}
@Component
public class Bmw implements Car {}
What is the advantage of using a @Qualifier
@Autowired
@Qualifier("toyota")
private Car car;
over using the specific implementation type when autowiring?
@Autowired
private Toyota car;
The downside of @Qualifier
I see here is losing "type-safety" by relying on a string that could get out of sync with the bean (class) name.
How to avoid this fragility? What is the advantage of @Qualifier
?