【问题标题】:Where is Spring ResourceSupportSpring 资源支持在哪里
【发布时间】:2020-03-20 02:04:47
【问题描述】:

我正在阅读 Spring in Action 5th。并添加 hatoas 超链接。这个类正在扩展org.springframework.hateoas.ResourceSupport 但是我找不到它。我正在使用 Spring Boot 版本 2.2.5.RELEASE

import org.springframework.hateoas.ResourceSupport;
import tacos.Taco;

@Relation(value = "taco", collectionRelation = "tacos")
public class TacoResource extends ResourceSupport {

    private static final IngredientResourceAssembler ingredientAssembler = new IngredientResourceAssembler();

    @Getter
    private final String name;

那么这个版本中这个类的名称是什么,因为源代码使用的是旧版本,我认为是 2.0.2 M1

【问题讨论】:

    标签: spring spring-boot spring-hateoas


    【解决方案1】:

    以下来自Spring HATEOAS documentation

    ResourceSupport/Resource/Resources/PagedResources 类组从来没有真正让人觉得命名合适。毕竟,这些类型实际上并不体现资源,而是可以通过超媒体信息和可供性丰富的表示模型。以下是新名称与旧名称的对应关系:

    ResourceSupport 现在是RepresentationModel

    Resource 现在是EntityModel

    Resources 现在是CollectionModel

    PagedResources 现在是PagedModel

    所以从 Spring HATEOAS 1.0 开始,ResourceSupport 就是 RepresentationModel

    Spring 还提供了一个migration script,它可以帮助用新的替换旧的 Spring HATEOAS 类型引用。

    【讨论】:

    • 哥们,你是救生员。在stackoverflow中他们应该是更多像你一样的人。谢谢并保持安全。
    • 我按回车键,新的 cmd 窗口打开又关闭,但没有任何变化
    猜你喜欢
    • 2014-12-19
    • 2014-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    • 2014-07-10
    相关资源
    最近更新 更多