我试图覆盖已在基础注射器中配置的子注射器中的绑定。
像那样: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抱怨它已经有了约束力。该问题是否有任何模式或最佳实践?