2011-10-30 79 views
5

GIN模塊:GWT GIN - 瑣碎的用例失敗(EventBus)

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 

回答

7

如果你使用GWT 2.4:

現在有兩個EventBus(一個已廢棄),請確保您使用在註冊者和您的入口點中是相同的類型。