GWT GIN Provider编译错误

时间:2012-11-17 20:55:30

标签: java gwt guice gin

我正在尝试配置我的GIN模块以将ActivityManager请求绑定到DefaultActivityManagerProvider

import com.google.inject.Provider;

public class DefaultActivityManagerProvider implements Provider<ActivityManager> {
    @Override
    public ActivityManager get() {
        return new ActivityManager(new MyDefaultActivityMapper());
    }
}

但是当我真正绑定它时:

public class MyAppGinModule extends AbstractGinModule {
    @Override
    protected void configure() {
        bind(ActivityManager.class).toProvider(DefaultActivityManagerProvider.class);
    }
}

我在bind(...)语句中遇到编译错误:

Bound mismatch: The generic method toProvider(Class<I>) of type
GinLinkedBindingBuilder<T> is not applicable for the arguments
(Class<DefaultActivityManagerProvider>). The inferred type
DefaultActivityManagerProvider is not a valid substitute for the
bounded parameter <I extends Provider<? extends ActivityManager>>

我在这里做错了什么?!?我已经关注了this one等无数例子,无法弄清楚我收到错误的原因!提前谢谢!

1 个答案:

答案 0 :(得分:3)

toProvider未得到适当支持

http://code.google.com/p/google-gin/wiki/GinFaq

http://code.google.com/p/google-gin/wiki/GuiceCompatibility

提供者需要是公共静态

static class DefaultActivityManagerProvider implements Provider<ActivityManager> {
    @Override
    public ActivityManager get() {
        return new ActivityManager(new MyDefaultActivityMapper());
    }
}