Guice 4.0beta вернет список элементов только для чтения. Поэтому я модифицирую код Джесси Уилсона следующим образом. Что вам нужно сделать, это предоставить список модулей и вычесть целевую привязку, которую вы хотите заменить.
Injector injector = Guice.createInjector(new TestGuiceInjectionModule(), Utils.subtractBinding(new GuiceInjectionModule(),Key.get(IInfoQuery.class)));
Функция
public static Module subtractBinding(Module module, Key<?> toSubtract) {
List<Element> elements = Elements.getElements(module);
return Elements.getModule(Collections2.filter(elements, input -> {
if(input instanceof Binding)
{
return !((Binding) input).getKey().equals(toSubtract);
}
return true;
}));
}