Spring Data REST automatically exposes REST APIs for repositories created by Spring Data. Adding its starter to an application already using Spring Data enables repository operations without writing REST controllers. section 7.2
A Spring Data REST application provides:
- Generated endpoints for repositories such as ingredients, tacos, orders, and users. section 7.2
- Support for repositories created through Spring Data JPA, Spring Data Mongo, and related projects. section 7.2
- Hypermedia links in responses, implementing HATEOAS navigation for clients that choose to use them. section 7.2
- An alternative to manually written Spring MVC REST controllers when repository operations are sufficient. section 7.4
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency>
Add the Spring Data REST starter to the build; autoconfiguration then exposes Spring Data repositories as REST resources. section 7.2
Inspecting an ingredient resource
After starting a repository-backed application, request /ingredients with curl to receive an embedded ingredient collection and _links entries for the collection and each resource. Request /ingredients/FLTO to inspect one ingredient directly. section 7.2
$ curl localhost:8080/ingredients
{
"_embedded" : {
"ingredients" : [ {
"name" : "Flour Tortilla",
"type" : "WRAP",
"_links" : {
"self" : {
"href" : "http://localhost:8080/ingredients/FLTO"
},
"ingredient" : {
"href" : "http://localhost:8080/ingredients/FLTO"
}
}
},
...
]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/ingredients"
},
"profile" : {
"href" : "http://localhost:8080/profile/ingredients"
}
}
}
The sample response shows an ingredient collection with embedded resources, self links, profile metadata, and resource links. section 7.2

