How to configure Spring Data REST to return the representation of the resource created for a POST request?

后端 未结 4 1765
粉色の甜心
粉色の甜心 2021-02-07 03:12

I am following the spring-data-rest guide Accessing JPA Data with REST. When I http post a new record it is inserted (and the response is a 201). That is great, but is there a w

4条回答
  •  无人共我
    2021-02-07 04:02

    If you are using Spring Boot, you can add the following lines to your application.properties file for POST (create) and PUT (update) respectively

    spring.data.rest.return-body-on-create=true
    spring.data.rest.return-body-on-update=true
    

提交回复
热议问题