基本インジェクターで既に構成されている子インジェクターのバインディングをオーバーライドしようとしています。
そのように:
public class PersistenceModule extends Abstract{
@Override
protected void configure() {
bind(IProductPersistenceHelper.class).to(ProductPersistenceHelper.class);
}
}
それから :
Injector injector = Guice.createInjector(new PersistenceModule());
injector.createChildInjector(new AbstractModule(){
@Override
protected void configure() {
bind(IProductPersistenceHelper.class).to(MockProductPersistenceHelper.class);
}
})
Guice は、そのためのバインディングが既にあると不平を言っています。その問題のパターンやベスト プラクティスはありますか?