Spring用@Autowire向一个类注入一个接口的两个实现类

@Service
public class AaaService implements IChangePassword {

@Override
public void changePassword(String username, String password) {
}

}

@Service
public class BbbService implements IChangePassword {

@Override
public void changePassword(String username, String password) {
}

}

public class AccountController extends BaseController {
@Autowired
@Qualifier("aaaService")
private IChangePassword aaaService;

@Autowired
@Qualifier("bbbService")
private IChangePassword bbbService;
}

猜你喜欢

转载自www.cnblogs.com/stitchZsx/p/9750077.html