I have two implementations of an interface
@Component
public ClassA implements SomeInterface {
}
@Component
public classB implements SomeInterface {
}
And then a consumer that needs an implementation of the class depending on some condition. How do I pick a particular bean?
@Component
public class Consumer {
@PickTheRightBean(if(condition) then pick SomeClassA else pick SomeClassB) \\ how do I do this?
private final SomeInterface myBean;
}
I tried @Conditional
annotation, but it still ends up picking the wrong bean.