2
votes

I have Maven project which uses another project as jar library. I have @Inject'ed UserService interface from jar and I get:

com.google.inject.ConfigurationException: Guice configuration errors: 1) No implementation for UserService was bound.

I have tried to bind UserService interface to the concrete class but later I get "No implementation for ... was bound" exceptions for classes injected into UserService. How to solve this problem?


public class UserServiceImpl implements UserService

@Override
protected void configure() {
    Properties configProperties = loadPropertiesFile("device.properties");
    bind(Properties.class).annotatedWith(AppProperties.class).toInstance(configProperties);

    Names.bindProperties(binder(), configProperties);
    Names.bindProperties(binder(), loadProperties("/" + GenericBootstrapConstants.BOOTSTRAP_PROPERTIES_FILE));

    bind(UserService.class).to(UserServiceImpl.class);
}
1
Can you show the code of the configure() method, and the class header of the class that implements UserService? - Pedro Gordo
You should configure every injected service which hasn't a default implementation. - Jérémie B
Should I configure within main project or in external project? Both uses Maven, Guice, JAX-RS. - Justinas Jakavonis
When I run external jar project separately, it works well without configuration. There is no interface which is implemented in more than 1 class. - Justinas Jakavonis
Hm ... this should work. Could you paste more code and/or stacktrace, please? - Jan Galinski

1 Answers

0
votes

I have bind() and addMapperClasses() for every injected service. Thanks Jérémie B