关于 spring 注解 Nullable 使用的困惑
資深大佬 : JCJD 0
package org.springframework.lang; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; // 在我的项目中未引入下面三个依赖 import javax.annotation.Nonnull; import javax.annotation.meta.TypeQualifierNickname; import javax.annotation.meta.When; @Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Nonnull(when = When.MAYBE) @TypeQualifierNickname public @interface Nullable { }
在缺少 javax.annotation.Nonnull,javax.annotation.meta.TypeQualifierNickname,javax.annotation.meta.When 类的情况下,Nullable依然可以正常使用,而不会出现类似’ClassNotFoundException’的错误,这是为什么呢?
大佬有話說 (4)