IDEA 不想使用 javax 中的 NotNull,而是使用 org.jetbrains

Ant*_*sok 5 java annotations jetbrains-ide intellij-idea notnull

当我在 DTO 中的 @NotNull 注释上看到这个时,我正在设置我的项目

Not 'javax.validation.constraints.NotNull' but 'org.jetbrains.annotations.NotNull' would be used for code generation
Run Code Online (Sandbox Code Playgroud)

我有 import javax.validation.constraints.NotNull;

但还是看到这个警告。

为什么 IDEA 不想使用 javax NotNull 以及我应该做什么来强制它?

mai*_*290 6

当您编译项目时,IDE 会将断言添加到使用 @NotNull 注释进行注释的所有方法和参数。如果在需要 @NotNull 的代码中传递 null,则断言将失败。您可以禁用此选项并在“设置/首选项”对话框 Ctrl+Alt+S中配置注释列表。转到构建、执行、部署 | 编译器

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

也许这会达到目的。