Spring Data Rest 存储库偶尔不导出 [英] Spring Data Rest repositories occasionally not exported

查看:41
本文介绍了Spring Data Rest 存储库偶尔不导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Spring Data Rest (3.2.6.RELEASE) 的 Spring Boot 应用程序 (2.2.6.RELEASE) 中遇到了一个奇怪的问题.有时我的存储库不会通过休息暴露.使用完全相同的配置,使用完全相同的应用程序版本(相同的 jar)会发生这种情况.

I'm having a weird issue in my Spring Boot application (2.2.6.RELEASE) using Spring Data Rest (3.2.6.RELEASE). From time to time my repositories are not exposed via rest. This is happening with the exact same version (same jar) of my application using the exact same configuration.

有 4 个 @RepositoryRestResource,当它工作时,根资源会暴露这个:

There are 4 @RepositoryRestResource's and when it's working, the root resource exposes this:

{
    "_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 启用调试日志记录会在两种情况下产生完全相同的输出
  • 比较执行器端点的响应没有显示任何明显差异
  • 存储库检测策略明确设置为 RepositoryDe​​tectionStrategies.ANNOTATED
  • 我无法在 SSCE 中复制它
  • 模块已从 Spring Boot 1.5.18 升级,升级后问题开始出现.
  • The JPA component scan is working in both scenarios
  • The repositories themselves are working cause in both scenarios, custom controllers using these repo's work fine
  • Enabling debug logging for org.springframework.data produces the exact same output in both scenarios
  • Comparing responses from actuator endpoints doesn't show any noticeable difference
  • Repository detection strategy is set to RepositoryDetectionStrategies.ANNOTATED explicitly
  • I cannot reproduce it in a SSCE
  • Module has been upgraded from Spring Boot 1.5.18, the issue started happening after the upgrade.

有没有其他人遇到过这个问题?这可能是什么原因造成的?或者关于如何进一步分析这个问题的一些指示?

Has anybody else experienced this issue before? What might be causing this? Or some pointers on how I can further analyse this problem?

推荐答案

听起来您遇到了 DATAREST-1502 已在 3.2.7 及更新版本中修复.

Sounds like you're running into DATAREST-1502 which has been fixed in 3.2.7 and newer.

这篇关于Spring Data Rest 存储库偶尔不导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆