我上课有最后的字段。当我在构造函数上验证我的字段时 - 有一个NullPointerException。我使用javax.validation.constraints.NotNull。 只有在我验证构造函数中的字段时才会发生这种情况。当我早点这样做 - 它的工作。你知道为什么吗? //它运作良好
public final class User {
@NotNull private final String name;
@NotNull private final List<Notes> notes;
@JsonCreator public User(String name, List<Notes> notes){
this.name = name;
this.notes = notes }
//It isn`t working, NPException
public final class User {
private final String name;
private final List<Notes> notes;
@JsonCreator
public User(@NotNull String name, @NotNull List<Notes> notes){
this.name = name;
this.notes = notes }