Picocontainer中的JSR-330支持:@Inject ... @Named(" xxx) [英] JSR-330 support in Picocontainer : @Inject ... @Named("xxx)
问题描述
我们找到了类似的代码
private String string = "Not injected.";
@Inject
public void setString(@Named("s") String s) {
this.string = s;
}
(利用JSR-330批注)对于传递"s"的字符串值非常有用.对于使用哪个容器,我们也希望尽可能灵活,因此也希望使用Picocontainer.
(utilitzing JSR-330 annotations) to be very useful to pass in a string value for "s". We would like to be as flexible as possible regarding which container to use, hence also Picocontainer.
按照书面规定,Picocontainer会默默地忽略注入.我将如何提示PicoContainer注入例如绳子注入了!"在这里?
As written, Picocontainer silently ignores the inject. How would I hint to PicoContainer to inject e.g. "String injected!" here?
推荐答案
稳定的pico 2.x不完全支持JSR-330(您的特殊情况),而pico 3.x则具有. 无论如何,@named并不是使用picocontainer功能的好方法,也不是针对以IoC为中心的应用程序的好设计.如果您使用这些东西,可能不需要pico.
Stable pico 2.x does not have full support for JSR-330 (your particular case), pico 3.x will have. Anyway, @named is not a good way to use picocontainer powers and not a good design for IoC centered app at all. Probably you don't need pico, if you use this stuff.
这篇关于Picocontainer中的JSR-330支持:@Inject ... @Named(" xxx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!