I'm developing REST service using Spring Boot. If I use a response entity, my model object is by default resulting in JSON.
In this case, do I need to specify consumes and produces attributes in each of the services?
I'm developing REST service using Spring Boot. If I use a response entity, my model object is by default resulting in JSON.
In this case, do I need to specify consumes and produces attributes in each of the services?
According to the documentation:
Consumes
For a
@WriteOperation(HTTPPOST) that uses the request body, the consumes clause of the predicate isapplication/vnd.spring-boot.actuator.v2+json, application/json. For all other operations the consumes clause is empty.
Produces
The produces clause of the predicate can be determined by the produces attribute of the
@DeleteOperation,@ReadOperation, and@WriteOperationannotations. The attribute is optional. If it is not used, the produces clause is determined automatically.If the operation method returns
voidorVoidthe produces clause is empty. If the operation method returns aorg.springframework.core.io.Resource, the produces clause isapplication/octet-stream. For all other operations the produces clause isapplication/vnd.spring-boot.actuator.v2+json, application/json.
So you are producing JSON by default unless you are returning a Resource, and then you are producing an octet-stream by default.