我正在尝试配置我的 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>>
我在这里做错了什么?!?我已经遵循了无数的例子,比如这个,但不知道为什么我会收到错误!提前致谢!