Guice配置错误:没有绑定xxx的实现

时间:2018-10-09 18:50:02

标签: java dependency-injection guice guice-3

我的处理程序类:

public class Handler {

      private final IStore dataStore;

      @Inject
      @Singleton
      public Handler(IStore dataStore) {
          this.dataStore = dataStore;
      }
    }
}

我的界面类:

public interface IStore {}

我的Impl课程:

public class DataStoreImpl implements IStore {
  private final JooqTransacter transacter;

  @Inject
  public DataStoreImpl(@Named("XXX") JooqTransacter transacter) {
    this.transacter = transacter;
  }
}

我要绑定的模块类:

public class StoreImplModule extends AbstractModule {
  @Override protected void configure() {
    bind(IStore.class).to(DataStoreImpl.class);
  }
}

当我运行它时,我不断收到此错误:

com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for com.xx.store.IStore was bound.
  while locating xxx.IStore
    for the 1st parameter of Handler.<init>(Handler.java:99)
  while locating com.xx.handlers.Handler

任何见解将不胜感激!

0 个答案:

没有答案