If an interface UserInterface has multiple implementation classes
AImpl(@service(name="userInterface1")) BImpl(@service(name="userInterface2"))
These implementation classes are added to the Spring container.
There are several ways to inject instances:
1. Distinguish different instances by adding the annotation @Qualifier
@Autowire @Qualifier("userInterface1") iUserInterface iUserInterface;
2. Distinguish different instances by @Resource(name="userInterface1")
@Resource(name="userInterface1") iUserInterface iUserInterface;
3. Keep userInterface consistent with the AImpl class object name (this method is not recommended)
@Autowired private IUserInterface userInterface1; @Autowired private IUserInterface userInterface2;