Spring boot 2.1.13.RELEASE hateoas链接响应与Spring boot 1.5.14.RELEASE hateoas链接响应

问题描述 投票:0回答:2

我们正在将Spring Boot项目从1.5.14.RELEASE升级到2.1.13.RELEASE。除了hateoas链接响应之外,其他一切都正常。

对于1.5.14.RELEASE,响应为:

{
    "_links": {
        "urn:eim:linkrel:config": {
            "href": "http://localhost:8080/v1/config"
        }
    }
}

对于2.1.13.RELEASE,响应为:

{
    "links": [
        {
            "rel": "urn:eim:linkrel:config",
            "href": "http://localhost:3000/v1/config",
            "hreflang": null,
            "media": null,
            "title": null,
            "type": null,
            "deprecation": null
        }
    ]
}

是否有像1.5.14.RELEASE中那样获得响应的备用方法?

spring spring-boot spring-mvc spring-hateoas
2个回答
0
投票

Spring Boot 1.5取决于Spring HATEOAS 0.23。

Spring Boot 2.1取决于Spring HATEOAS 0.25.2。

Spring HATEOAS的大多数修复和改进都在1.0 / 1.1上,而Spring Boot 2.2和2.3支持。

由于在1.0上进行了所有结构性更改,几乎没有更改都被反向移植到0.25.x。


0
投票

最后,我在此链接中找到了答案:https://docs.spring.io/spring-hateoas/docs/current/reference/html/#mediatypes.hal.curie-provider

通过在配置文件上添加此批注@EnableHypermediaSupport(type = {HypermediaType.HAL}),我能够以所需的方式获得链接响应。

© www.soinside.com 2019 - 2024. All rights reserved.