java - 找不到类型类调试错误的 PersistentEntity
问题描述
我有以下代码尝试将文档对象插入 mongoDB。
return reactiveMongoTemplate.insert(document)
.doOnSuccess(filler -> System.out.println(filler))
.onErrorResume(e -> {
String message = format("Error saving %s", e.getMessage());
log.error(message, e);
throw new PersistenceException(message, e);
})
.block();
当我调试时,我收到一个错误,上面写着 org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class org.bson.Document!
这被标识为在返回的第一行。有谁知道为什么会这样?
解决方案
这似乎是一个错误(至少它类似于这个报告的问题)。无论如何,似乎包含集合名称作为第二个参数的插入方法确实可以正常工作:
return reactiveMongoTemplate.insert(document, "documentCollection")
// ...
这对我有用。
推荐阅读
- java - 无法处理 jar 文件中的按钮单击
- wso2 - 第一个使用 WSO2 APIM 4.0.0 的 API,创建似乎很好,但尝试调用 API 时出现 HTTP 404
- javascript - Jest 测试运行器在测试字符串中的某些字符上失败
- scikit-learn - scikit-learn GridSearchCV 与管道作为估计器:如何在管道中获取估计器的属性?
- javascript - 使用 JSX 作为字符串反应组件内容
- r - R FuzzyJoin by 带有变量的子句
- vue.js - 如何在 Vue cli 项目中禁用 eslint 错误?
- flutter - Flutter/Dart - 尝试迭代值映射 // 需要语法帮助
- sql - 使用条件插入全部替换数据保险库模型中多个表的合并语句是否会减少摄取时间?
- mysql - 像 jan=Jan 和 feb =jan+feb 使用 mysql 和 March 的月份总和 = jan+feb+march