As the title says, I wonder if I still need to declare produces = MediaType.APPLICATION_JSON_VALUE in a controller's method if the controller is already annotated with @RestController? I'm working on an old legacy application where all the controller methods have this declared. Spring Boot Initializr generates a default REST controller without it and even if I omit MediaType.APPLICATION_JSON_VALUE, it still works without any problems.
I remember to have seen somewhere that is supposed to be as default. Correct or not?
@RestController
@RequestMapping("/posts")
@Slf4j
public class PostsController {
@PutMapping(value = "posts/{post_d}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Post> getPost(@PathVariable Long postId) {
...
}
}