Google News
logo
Java Spring Boot - Interview Questions
What do you understand by Spring Data REST?
Spring Data REST is used to expose the RESTful resources around Spring Data repositories. Consider the following example :
 
@RepositoryRestResource(collectionResourceRel = "sample", path = "sample")
public interface SampleRepository
        extends CustomerRepository<sample, Long> {
 
Now, to expose the REST services, you can use the POST method in the following way:
 
{
"customername": "Venkat"
}
 
Response Content

{
"customername": "Venkat"
"_links": {
"self": {
"href": "http://localhost:8080/sample/1"
},
"sample": {
"href": "http://localhost:8080/sample/1"
}
}
 
Observe that the response content contains the href of the newly created resource.
Advertisement