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

2

5

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?

Mala answered 5/9, 2018 at 7:51 Comment(0)
S
6

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.

Splice answered 5/9, 2018 at 8:0 Comment(0)
S
1

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

Showdown answered 30/8, 2023 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.