guice multibinder with Providers

前端 未结 2 885
谎友^
谎友^ 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:23

    Though Guice seems to be very good about using JSR-330 annotations interchangeably, it seems that Multibindings hides the Provider type within a Map and therefore may be expecting to inject a java.util.Map> instead. I haven't been able to reproduce your problem, but try that and see if it helps.

    Side note: If you want to avoid changing it in code everywhere, you can hackishly bind a provider of Map> to something that takes in the multibinder-created Map>. If I'm right and this is the problem, you can fix it one place rather than bouncing between javax.inject and com.google.inject everywhere.

提交回复
热议问题