java - spring-data-elasticsearch 不支持@NotNull 或@NotEmpty 注释吗?
问题描述
我现在正在使用最新的 spring-data-elasticsearch ,我只是尝试使用 Spring 验证注释(如、spring-boot 2.4.5
等)验证我的实体(将映射到我的弹性搜索集群上的文档中)。@NotNull
@NotEmpty
但是,这些注释不起作用;即使我将 null 传递给字段(用 标记@NotNull
),也没有发生错误。
这是我的 Document 实体:
@Builder
@Document(indexName = "testidx", createIndex = false)
public class Book implements Persistable<String> {
@Id
private final String _id;
@NotNull
@CreatedDate
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
private final Instant regTime;
@NotNull // this annotations aren't working
private final String bookName;
// ...
}
我试图在官方参考资料中找到一些用例,但我找不到任何用例。spring-data-elasticsearch 不支持 Spring 验证注解吗?
谢谢!
解决方案
推荐阅读
- gtk3 - 尝试在 C 中使用 cario 导航 gdk_pixbuf 起点的问题
- python - Subprocess.call 外部程序
- c - 无法使用 C 在 Linux 中创建链表
- windows - Windows 10 最新更新 - Laravel Valet - 在一个驱动器中创建站点链接
- react-native - 在不支持它的国家/地区测试 google pay
- javascript - 无法在 GHCJS 中触发`dispatchEvent`
- javascript - 如何使用 puppeteer 点击动态 xpath?
- excel - Excel VBA没有按照我想要的方式读取日期数据
- python - Flask、Jinja2、Plotly:从网站回调点击事件数据到 Python 脚本
- c# - 如何通过ajaxfileupload获取上传文件列表