'No injectable members ...' is an error?
Consider that DeleteBastion class has no injectable members and I have a factory class as follows:
@Singleton
public static class Factory {
@Inject
MembersInjector<DeleteBastion> injector;
public DeleteBastion create(Regions region, Environment env) {
DeleteBastion cmd = new DeleteBastion(region, env);
injector.injectMembers(cmd);
return cmd;
}
}
Compiling gives me the following error:
Error:(43, 8) java: No injectable members on DeleteBastion. Do you want to add an injectable constructor? required by DeleteBastion.Factory for Main
Now, the error message is pretty obvious since I don't have an injectable member in the DeleteBastion, but that is quite inconvenient. Right now I don't have an injectable member, but it is quite possible that I may have one in the future. Does that mean I need to manage this by commenting out code and uncommenting it when I do have an injectable member? Shouldn't this be a warning at most or am I missing something?
As the logs suggest:
Do you want to add an injectable constructor?
This is what I usually do if I inject the class that doesn't have an injectable member. you can just add
@Inject public void DeleteBastion() {}
and you will not get an error. In the future if you want to inject a member in that class, just do that and remove the default constructor with the @Inject annotation.