spring-guides / tut-rest

Building REST services with Spring :: Learn how to easily build RESTful services with Spring

Home Page:https://spring.io/guides/tutorials/rest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EntityModel is Deprecated

firewater opened this issue · comments

Closed by author and moved to issue #88 instead. Thanks.

The Spring HATEOAS section of the tutorial contains deprecated code, according to IntelliJ. Specifically, EntityModel:

@GetMapping("/employees/{id}")
EntityModel<Employee> one(@PathVariable Long id) {

  Employee employee = repository.findById(id)
    .orElseThrow(() -> new EmployeeNotFoundException(id));

  return new EntityModel<>(employee,
    linkTo(methodOn(EmployeeController.class).one(id)).withSelfRel(),
    linkTo(methodOn(EmployeeController.class).all()).withRel("employees"));
}

This page recommends using of(object, iterable) instead.

This is my first exposure to Spring so I have no idea what I am doing. Can we please have the tutorial updated? Thanks.