gpt4 book ai didi

gwt - 工厂 "Unable to create or inherit binding"的 GIN AssistedInject 问题

转载 作者:行者123 更新时间:2023-12-01 12:45:36 24 4
gpt4 key购买 nike

我遇到一个奇怪的错误,在使用辅助注入(inject)时我无法克服:

[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){
}
}

这就是我尝试注入(inject)我的工厂以供使用的方式:

@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。

谢谢,

凯西

最佳答案

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

install(new GinFactoryModuleBuilder()
.implement(DOMModel.class, SyncedDOMModel.class)
.build(EditorClientFactory.class));

关于gwt - 工厂 "Unable to create or inherit binding"的 GIN AssistedInject 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16311419/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com