[英]GWT GIN - trivial use-case fails (EventBus)
GIN模塊:
public class InjectorModule extends AbstractGinModule {
@Override
protected void configure() {
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
}
}
注射器:
@GinModules(InjectorModule.class)
public interface Injector extends Ginjector {
EventBus getEventBus();
}
GWT模塊入口點:
public class Module1 implements EntryPoint {
private final Injector injector = GWT.create(Injector.class);
public void onModuleLoad() {
injector.getEventBus();
}
}
刪除對injector.getEventBus()
調用使一切正常。 調用injector.getEventBus()
會導致:
Caused by: java.lang.RuntimeException: Deferred binding failed for 'com.google.web.bindery.event.shared.EventBus' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.XXX.app.client.InjectorImpl.create_Key$type$com$google$web$bindery$event$shared$EventBus$_annotation$$none$$(InjectorImpl.java:72)
at com.XXX.app.client.InjectorImpl.get_Key$type$com$google$web$bindery$event$shared$EventBus$_annotation$$none$$(InjectorImpl.java:86)
at com.XXX.app.client.InjectorImpl.getEventBus(InjectorImpl.java:7)
at com.XXX.app.client.Module1.onModuleLoad(Module1.java:24)
GWT開發模式說:
23:58:50.287 [ERROR] Deferred binding result type 'com.google.web.bindery.event.shared.EventBus' should not be abstract
如果你使用gwt 2.4:
現在有兩個EventBus(一個不推薦使用)確保你在injetor和入口點使用相同的類型。
注意:如果您正在使用GWT活動並遇到此問題,請使用解決方法為此票證加注星標。 https://code.google.com/p/google-web-toolkit/issues/detail?id=6653
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.