I’m trying to inject typed object into service class but getting
com.google.inject.ConfigurationException: Guice configuration errors:
1) No implementation for com.bookpac.utils.appserver.ILookup<com.bookpac.server.common.IWS> was bound.
while locating com.bookpac.utils.appserver.ILookup<com.bookpac.server.common.IWS>
for parameter 0 at com.bookpac.server.LookupService.<init>(LookupService.java:13)
while locating com.bookpac.server.LookupService
Field to be injected is ILookup<IWS> lookup,
binding is bind(ILookup.class).toProvider(LookupProvider.class)
When using @Provides annotation everything works fine, any ideas ?
When you use generic types you need to use a TypeLiteral like :
bind(new TypeLiteral<ILookup<IWS>>(){}).toProvider(LookupProvider.class);From the documentation :