A developer needs to create a REST endpoint that returns a `201 Created` status code upon successful creation of a resource, and a response body containing the newly created object. Which approach is most appropriate for this scenario in a Spring Boot controller?
-
A
Return a `ResponseEntity` object, explicitly setting the status to `HttpStatus.CREATED` and including the object in the body.
-
B
Annotate the controller method with `@ResponseStatus(HttpStatus.CREATED)` and return the created object directly.
-
C
Return the created object directly and let Spring Boot default to a `200 OK` status, as the client can infer success.
-
D
Throw a custom `ResourceCreatedException` annotated with `@ResponseStatus(HttpStatus.CREATED)`.