java - Spring Data Rest 存储库偶尔不会导出
问题描述
我在2.2.6.RELEASE
使用 Spring Data Rest ( 3.2.6.RELEASE
) 的 Spring Boot 应用程序 () 中遇到了一个奇怪的问题。有时我的存储库不会通过休息暴露。这发生在我的应用程序的完全相同的版本(相同的 jar)中,使用完全相同的配置。
有 4 @RepositoryRestResource
,当它工作时,根资源会暴露这个:
{
"_links": {
"entity-a": {
"href": "http://localhost:8080/api/entity-a{?projection}",
"templated": true
},
"entity-b": {
"href": "http://localhost:8080/api/entity-b"
},
"entity-c": {
"href": "http://localhost:8080/api/entity-c{?page,size,sort,projection}",
"templated": true
},
"entity-d": {
"href": "http://localhost:8080/api/entity-d"
},
"profile": {
"href": "http://localhost:8080/api/profile"
}
}
}
当它不工作时它会返回:
{
"_links": {
"profile": {
"href": "http://localhost:8080/api/profile"
}
}
}
一些额外的发现:
- JPA 组件扫描在两种情况下都有效
- 存储库本身在这两种情况下都是有效的,使用这些存储库的自定义控制器工作正常
- 启用调试日志记录
org.springframework.data
会在两种情况下产生完全相同的输出 - 比较来自执行器端点的响应没有显示任何明显的差异
- 存储库检测策略设置为
RepositoryDetectionStrategies.ANNOTATED
显式 - 我无法在 SSCE 中复制它
- 模块已从 Spring Boot 1.5.18 升级,升级后问题开始出现。
以前有没有其他人遇到过这个问题?这可能是什么原因造成的?或者关于如何进一步分析这个问题的一些指示?
解决方案
听起来您遇到了DATAREST-1502,它已在 3.2.7 及更高版本中修复。
推荐阅读
- azure - Azure Powershell Get-AzDataFactory 返回错误:在命名空间“Microsoft.DataFactory”中找不到资源类型
- php - 如何优化过滤系统中多个“LIKE”搜索中的慢 MySQL 查询?
- node.js - Gatsby 的插件生成 sitemap.xml 返回 404 错误
- java - 如何在其中实例化 Guice 模块时使类的构造函数单元可测试?
- javascript - JS:组合对象属性
- uwp - 屏幕截图视频颜色比屏幕上的颜色更亮或更暗
- opengl-es - WebGL2 - 在任意位置写入纹理/缓冲区 - OpenGL imageStore 等效
- sql - 如何忽略表中行之间的前后值
- css - 如果在angular8中用完工具栏,如何换行
- python - 如何在 Django 中组织缓存?