Anton Kolosok
Anton Kolosok

Reputation: 522

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?

Upvotes: 6

Views: 5335

Answers (2)

Peter Wippermann
Peter Wippermann

Reputation: 4599

In addition to maio290 's answer, it's important you change the "annotiation used for code generation" setting: screenshot of configure nullability/nonnull annotatioons dialog

Upvotes: 1

maio290
maio290

Reputation: 6742

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.

Upvotes: 7

Related Questions