Upgrade to latest Spring HATEOAS API changes.

This commit is contained in:
Greg Turnquist
2019-03-03 10:52:08 -06:00
parent 35c74de6cb
commit 15db5a0513
28 changed files with 185 additions and 180 deletions

View File

@@ -18,12 +18,12 @@ package org.springframework.hateoas.examples;
import java.net.URI;
import java.net.URISyntaxException;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.client.Traverson;
import org.springframework.hateoas.mvc.TypeReferences.ResourcesType;
import org.springframework.hateoas.server.core.TypeReferences.CollectionModelType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@@ -62,9 +62,9 @@ public class HomeController {
public String index(Model model) throws URISyntaxException {
Traverson client = new Traverson(new URI(REMOTE_SERVICE_ROOT_URI), MediaTypes.HAL_JSON);
Resources<Resource<Employee>> employees = client
CollectionModel<EntityModel<Employee>> employees = client
.follow("employees")
.toObject(new ResourcesType<Resource<Employee>>(){});
.toObject(new CollectionModelType<EntityModel<Employee>>(){});
model.addAttribute("employee", new Employee());
model.addAttribute("employees", employees);