Guice child injector override binding
- by Roman
Hi All
I am trying to to override a binding in a child injector that was already configured in a base injector.
like that :
public class PersistenceModule extends Abstract{
@Override
protected void configure() {
bind(IProductPersistenceHelper.class).to(ProductPersistenceHelper.class);
}
}
then :
Injector injector = Guice.createInjector(new PersistenceModule());
injector.createChildInjector(new AbstractModule(){
@Override
protected void configure() {
bind(IProductPersistenceHelper.class).to(MockProductPersistenceHelper.class);
}
})
Guice is complaining that it has already a binding for that. Are there any patterns or best practices for that problem ?