Spring Boot starter HATEOAS

Spring Boot has a specific starter for HATEOAS called spring-boot-starter-hateoas. We need to add it to the pom.xml file.

The following code snippet shows the dependency block:

    <dependency>      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-starter-hateoas</artifactId>    </dependency>

One of the important dependencies of spring-boot-starter-hateoas is spring-hateoas, which provides the HATEOAS features:

    <dependency>      <groupId>org.springframework.hateoas</groupId>      <artifactId>spring-hateoas</artifactId>    </dependency>

Let's enhance the retrieveTodo resource (/users/{name}/todos/{id}) to return a link to retrieve all todos (/users/{name}/todos) in the response:

 @GetMapping(path = "/users/{name}/todos/{id}") ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.