Spring提供的 编译期(Idea\Eclipse编译时检查,需设置开启) Null-safety检查

  • @Nullable:字段可以为空
  • @NonNull:字段不能为空
  • @NonNullApi: 包级别,参数和返回值非null
  • @NonNullFields:包级别,字段默认非空

package-info.java 放在需检查的包路径下

/**
 * Provides basic classes for exception handling and version detection,
 * and other core helpers that are not specific to any part of the framework.
 */
@NonNullApi //所有参数和返回值非null;如有字段需设置可为空,使用@Nullable
@NonNullFields
package org.springframework.core; //检查org.springframework.core包下的所有字段

import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;

相关文章:

  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2021-09-09
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2021-10-06
  • 2021-12-27
  • 2021-12-10
  • 2021-07-22
  • 2021-06-30
  • 2022-02-23
相关资源
相似解决方案