Reputation: 95
I have a piece of code with a couple of Modules from different libraries:
install(new AModule())
install(new BModule())
I am getting an error:-
A binding to com.path.to.Class was already configured at com.AModule.provideClass. at com.BModule...
I need both the modules but they cannot be used together because both have bindings to a particular class. I do not own the 2 libraries so cannot make changes there. How can I solve this issue?
Upvotes: 1
Views: 6130
Reputation: 35417
Modules.override
If you require the binding present in AModule
, use:
install(Modules.override(new BModule()).with(new AModule()));
On the other hand, if you require the binding present in BModule
, use:
install(Modules.override(new AModule()).with(new BModule()));
Upvotes: 4