GWT GIN - 琐碎的用例失败(EventBus)

时间:2011-10-30 06:50:12

标签: java gwt

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

2 个答案:

答案 0 :(得分:7)

如果您使用的是gwt 2.4:

现在有两个EventBus(一个被弃用)确保你在injetor和入口点使用相同的类型。

答案 1 :(得分:0)

注意:如果您使用GWT活动并遇到此问题,请使用解决方法为此故障单加注星标。 https://code.google.com/p/google-web-toolkit/issues/detail?id=6653