【发布时间】:2018-02-09 02:51:24
【问题描述】:
我正在尝试在 Guice 中注入一个字符串数组列表。为此,我尝试在模块中构建如下列表,稍后我可以将其注入任何类:
Multibinder<String> myList =
Multibinder.newSetBinder(binder(), String.class);
myList.addBinding().to("Test1");
myList.addBinding().to("Test2");
在上述行中,我收到以下错误:
The method to(Class<? extends String>) in the type LinkedBindingBuilder<String> is not applicable for the arguments (String)
在这种情况下,我发现了这个:Guice : Inject an ArrayList of Strings,但我认为给定的解决方案不适合我的用例。
【问题讨论】:
-
你的数组列表在哪里?你想把它注入什么?