问题
We have found code like
private String string = "Not injected.";
@Inject
public void setString(@Named("s") String s) {
this.string = s;
}
(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.
As written, Picocontainer silently ignores the inject. How would I hint to PicoContainer to inject e.g. "String injected!" here?
回答1:
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.
来源:https://stackoverflow.com/questions/14440363/jsr-330-support-in-picocontainer-inject-namedxxx