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}") ...