I have a question related to the case where one wants to inject stuff into instances of external libraries, 开发者_运维知识库i.e. classes that cannot be annotated with injection annotations.
Since Guice relies exclusively on annotations, does this mean I cannot handle this use case with Guice? With Spring, I can just declare the injection in XML and there's no need to modify the class (by adding annotations), so it just works.
Are these observations correct and if so, how do you solve the problem when using Guice?
With Guice you can use provider methods, provider bindings, instance bindings (for singletons) and constructor bindings. They don't require the presence of an @Inject annotation.
精彩评论