guice multibinder with Providers

前端 未结 2 877
谎友^
谎友^ 2021-01-07 10:34

I am trying to be able to have this in my code

@Inject
private Map> providers;

I was trying but thi

2条回答
  •  轮回少年
    2021-01-07 11:32

    If you want Map> at the injection point, the way to bind it is:

    MapBinder mapbinder = MapBinder.newMapBinder(binder, String.class, Processor.class); mapbinder.addBinding("splineV1Beta").to(SplineProcessor.class); mapbinder.addBinding("invertV1Beta").to(InvertProcessor.class);

    You would use toProvider() if you are supplying a custom provider, which you are not, i.e. you are merely trying to use the implicit underlying provider.

提交回复
热议问题