Reputation: 282
IntelliJ keeps telling me i have to initialize my injected fields. I know a workaround would be to create a ctor and annotate it with @Inject but i dont want to change all of my classes. So is there a way to tell IntelliJ to ignore this error in @Inject fields?
import jakarta.inject.Inject;
import org.eclipse.jdt.annotation.NonNull;
public class Foo {
@NonNull
@Inject
private Bar bar;
}
Under Settings -> Inscpections -> Probable bugs -> Nullability problems -> "@NotNull field is not initialized" there is a checkbox that is called "Ignore fields which could be initialized implicitly" that is checked. But it doesn't work.
Upvotes: 1
Views: 45
Reputation: 23
I have one idea: The default inspection profile does inspections for all languages, irrespective if you use it in your project or not. Did you try with a new custom inspection profile, disable all non-java inspections there (or keep only the languages your project uses) and check again?
I had "Field injection is not recommended" many times popping up until I noticed those are wrt Spring Framework - and our project does not use Spring!
Upvotes: 0