以下代码没有抛出任何错误,它是一个独立的Java程序。如果传递null,则会在控制台中打印null。请帮助我,如何启用@notnull注释。
import javax.validation.constraints.NotNull;
public class TestNotNull {
public void testNotNull(@NotNull(message = "name is compulsory") String name)
{
System.out.println(name);
}
public static void main(String... args)
{
TestNotNull testNotNull = new TestNotNull();
testNotNull.testNotNull(null);
}
}