3

我收到一个奇怪的错误,在使用辅助注射时我无法克服:

[DEBUG] [project] - Rebinding com.gwtplatform.mvp.client.DesktopGinjector
[DEBUG] [project] - Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
    [ERROR] [project] - Factory com.jorsek.editor.gin.EditorClientFactory could not be created
    [ERROR] [project] - Error injecting com.jorsek.editor.gin.EditorClientFactory: Unable to create or inherit binding: No @Inject or default constructor found for com.jorsek.editor.gin.EditorClientFactory

所需节点的路径:

com.projectname.client.application.resourceworkspace.ResourceWorkspacePresenter [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:122)] -> com.jorsek.editor.gin.EditorClientFactory [@Inject com 的构造函数.projectname.client.application.resourceworkspace.ResourceWorkspacePresenter]

这是我进行所有设置的方式:

我的工厂:

public interface EditorClientFactory {

/**
 * Create a new DOMModel via assisted injection initializing the model 
 * with the document entity and it's DOM document content.
 * 
 * @param document
 * @param domDocument
 * @return
 */
public DOMModel create(Entity document, Document domDocument);
}

我的模块:

public class EditorClientModule extends AbstractGinModule {

@Override
protected void configure() {

    install(new GinFactoryModuleBuilder().build(EditorClientFactory.class));

    bind(DOMModel.class).to(SyncedDOMModel.class);
}

}

com.jorsek.editor.impl.SyncedDOMModel:

public class SyncedDOMModel implements DOMModel {



@Inject
private SyncedDOMModel(){} /* For GIN/GUICE */

@AssistedInject
public SyncedDOMModel(CollabClient client, CollabClientFactory collabFactory, @Assisted Entity ref, @Assisted Document domDoc){
    }
}

这就是我试图注入我的工厂以供使用的方式:

@AssistedInject
public ResourceWorkspacePresenter(final EventBus eventBus, final MyView view, final MyProxy proxy, APIService apiService, EditorClientFactory editorFactory, @Assisted EntityLocator entityLocator) {
    super(eventBus, view, proxy, ApplicationPresenter.TYPE_SetMainContent);


    this.editorFactory = editorFactory;
    this.apiService = apiService;
     System.out.println("E Locator: " + entityLocator);

}

这就是我试图使用我的工厂的方式(虽然永远不会走这么远):

editorFactory.create(doc, domDoc);

谁能明白为什么会发生这种情况?

如果有帮助,我正在使用 GWTP RC2。

谢谢,

凯西

4

1 回答 1

4

您的代码不正确(我不知道它是否会解决您的问题,但这是一个开始):您不应该bind(DOMModel.class)而是告诉工厂:

install(new GinFactoryModuleBuilder()
    .implement(DOMModel.class, SyncedDOMModel.class)
    .build(EditorClientFactory.class));
于 2013-05-01T09:07:42.867 回答