@Entity
class Student{
@NotNull
private int sid;
@NotNull
private String sname;
private int age;
}
我必须显示包含 @NotNull 注释的字段的名称
我创建了一个函数
public boolean hasNotNull() {
return Arrays.stream(this.getClass().getDeclaredFields())
.anyMatch(field -> field.isAnnotationPresent(NotNull.class));
}
public Object[] getValue() {
if (hasNotNull())
return Arrays.stream(this.getClass().getDeclaredFields())
.filter(field -> field.isAnnotationPresent(NotNull.class)).toArray();
else
return null;
}
但我收到 500 内部服务器错误。
以下是警告:
WARNING: An illegal reflective access operation has occurred
WARNING: Please consider reporting this to the maintainers of com.fasterxml.jackson.databind.util.ClassUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
我应该怎么办?