Suppose I have two modules ModuleA
and ModuleB
which are self-sufficient and can be used as stand-alone modules. Both the modules have a dependency on a third module ModuleC
like
install(new ModuleC());
Now, I have a use case where I need to create an injector with both modules, A and B. I did this:
Guice.createInjector(new ModuleA(), new ModuleB());
It threw a CreationException
as expected which said that a binding to a certain class was already configured at one of the modules. Keeping in mind that I do not have the power to alter ModuleA
and ModuleB
, how do I make it work?
I tried using Modules.combine(Modules... modules)
but that did not solve my problem. Is there any solution out there for this?