Search code examples
javaintellij-ideaannotationsjetbrains-idenotnull

IDEA doesn't want to use NotNull from javax, but instead use org.jetbrains


I was setting up my project when I saw this on a @NotNull annotation in my DTOs

Not 'javax.validation.constraints.NotNull' but 'org.jetbrains.annotations.NotNull' would be used for code generation

I have import javax.validation.constraints.NotNull;
but I still see this warning.

Why doesn't IDEA want to use javax NotNull and what should I do to force it?


Solution

  • When you compile your project, the IDE adds assertions to all methods and parameters annotated with the @NotNull annotation. The assertions will fail if null is passed in code where @NotNull is expected. You can disable this option and configure the list of annotations in the Settings/Preferences dialog Ctrl+Alt+S. Go to Build, Execution, Deployment | Compiler.

    https://www.jetbrains.com/help/idea/nullable-and-notnull-annotations.html

    Maybe this would to the trick.