I have 2 classes implementing InterfaceA
@Service("classA")
class ClassA implements InterfaceA
@Service("classB")
class ClassB implements InterfaceA
I need to load both beans. In class C and D, though, I need to specify the bean that I need
class ClassC {
@Autowired
@Qualifier("classA")
private InterfaceA interf;
}
class ClassD {
@Autowired
@Qualifier("classA")
private InterfaceA interf;
}
However, I have 2 profiles, profile1 and profile2. If i use -Dspring.profiles.active=profile1, I should be using qualifier "classA" for classC and classD. If i use -Dspring.profiles.active=profile2, I should use "classB" as qualifier. Also, another ClassE should always use classB regardless of the profile. Can you please advise how should I do it?