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.
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.
Share Improve this question edited Feb 5 at 9:51 unrated asked Feb 5 at 9:36 unratedunrated 2821 gold badge5 silver badges24 bronze badges1 Answer
Reset to default 0I 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!