VishalDevgire VishalDevgire - 7 days ago 7x
Java Question

How to have a @PATCH annotation for JAX-RS?

JAX-RS has annotations for HTTP verbs such as

) and
) but there is no
annotation. How can I have an annotation for the
HTTP verb?

Something like the following:

public Response someCode() {
// Code to handle the request


I got answer here.

One will just have to define a custom Patch annotation, what that means is that you will have to write a file with following code:

public @interface PATCH {

Import the package containing and then you can use it like other HTTP method annotations:

@Produces({ "application/json" })
public void patchRow(@PathParam("keyspace") String keyspace, String body) 
throws Exception

I used this @PATCH to send some JSON to my REST service.