我正在阅读Spring in Action 5th。并添加hateoas超链接。此类正在扩展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 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类型引用。