I'm trying to do an injection at the field level, so I don’t need to pass “models” when my controllers are created, for example
UserController controller = new UserController();
However, my application raises a NullPointerException, here is my code:
UserController.java
public class UserController implements Controller {
@Inject private UserModel model;
public UserController() {
model.doSomething();
}
}
ClientGinModule.java
public class ClientGinModule extends AbstractGinModule {
@Override
protected void configure() {
bind(UserModel.class).in(Singleton.class);
}
}
What could be the problem?
source
share