Annotation Type Produces


@Target({TYPE,METHOD}) @Retention(RUNTIME) public @interface Produces
Specify endpoint response media type. When not specified the default MediaType is application/json, so we specify this on controllers or methods where the responses return a different media type.


  @Produces(MediaType.TEXT_PLAIN)
  @Path("/customers")
  class CustomerController {
    ...
  }

 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The status code of the route when successful.
    Specify response media type.
  • Element Details

    • value

      String value
      Specify response media type.

      When not specified the default MediaType is application/json

      Default:
      "application/json"
    • statusCode

      int statusCode
      The status code of the route when successful.

      When not specified, the default status are as follows:
      GET(200)
      POST(201)
      PUT(200, void methods 204)
      PATCH(200, void methods 204)
      DELETE(200, void methods 204)

      Default:
      0