Open GoogleCodeExporter opened 9 years ago
Calling injector.injectMembers(instance) asks Guice inject any fields or setter
methods in the instance that are declared with @Inject. Guice has no way to
know that these fields have already been injected, for example they could have
default values that should be overwritten by the configured value.
The safest way to avoid this kind of re-injection, when you're using multiple
injection frameworks to configure the same instance, is to use constructor
injection for the primary properties. You can then use setter or field
injection for any secondary properties supplied by the other framework.
If constructor injection is not an option then you could always use setter
injection, and put a guard condition in your setter methods to ignore
subsequent calls.
Original comment by mccu...@gmail.com
on 12 May 2013 at 9:35
Original issue reported on code.google.com by
dave.che...@gmail.com
on 25 Apr 2013 at 8:50