I'm trying to use Google Guice in my application. So I created a Module binding an interface with an implementation ...
public class ApplicationModule extends AbstractModule {
@Override
protected void configure() {
super.configure();
bind(UserDAO.class).in(Singleton.class);
bind(UserDAO.class).to(UserDAOImpl.class);
}
}
But when I'm going to instantiate the injector using
Injector injector = Guice.createInjector(new ApplicationModule());
Google Guice says that the bind has not been done ...
com.google.inject.CreationException: Unable to create injector, see the following errors:
1) No implementation for br.com.brunots.training.simple_rest_application.dao.UserDAO was bound.
Did you mean?
br.com.brunots.training.simple_rest_application.dao.UserDAO bound at br.com.brunots.training.simple_rest_application.guice.ApplicationModule.configure(ApplicationModule.java:16)
at br.com.brunots.training.simple_rest_application.guice.ApplicationModule.configure(ApplicationModule.java:15)
2) A binding to br.com.brunots.training.simple_rest_application.dao.UserDAO was already configured at br.com.brunots.training.simple_rest_application.guice.ApplicationModule.configure(ApplicationModule.java:16).
at br.com.brunots.training.simple_rest_application.guice.ApplicationModule.configure(ApplicationModule.java:15)
What am I doing wrong?