Spring ResourceSupport 在哪里

use*_*est 5 spring spring-hateoas spring-boot

我正在读《春天在行动》第五期。并添加 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;
Run Code Online (Sandbox Code Playgroud)

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

Mad*_*hat 14

以下来自Spring HATEOAS 文档

\n
\n

ResourceSupport/ Resource/ Resources/PagedResources命名合适。毕竟,这些类型实际上并不体现资源,而是可以通过超媒体信息和可供性来丰富的表示模型。这里\xe2\x80\x99是新名称如何映射到旧名称的:

\n

ResourceSupport就是现在RepresentationModel

\n

Resource就是现在EntityModel

\n

Resources就是现在CollectionModel

\n

PagedResources就是现在PagedModel

\n
\n

所以从Spring HATEOAS 1.0开始,ResourceSupportRepresentationModel

\n

Spring也提供了迁移脚本,可以帮助用新的引用替换旧的 Spring HATEOAS 类型引用。

\n