title: jersey: possible to inherit path from parent class
body: <p>In the spirit of DRY I'm trying to bundle annotations and shared code that apply to all my REST resources in a central class. Sharing parts of the path does not seem to work.</p>
  
  <p>Let's say I have two REST resources at <code>/v1/users</code> and <code>/v1/items</code>. The Jersey resources both extend the same parent class <code>V1BaseResource</code>. Can they inherit the <code>v1</code>-part of the path?</p>
  
  <p>Example:</p>
  
  <pre><code>@Path("v1")
  @Produces(MediaType.APPLICATION_JSON)   // applies to all child-classes
  public class V1BaseResource {
  
      // maybe even some shared code
  }
  </code></pre>
  
  <p>UsersResource</p>
  
  <pre><code>@Path("users")
  public class UsersResource extends V1BaseResource {
  
      @GET
      public Response getUsers() ...
  }
  </code></pre>
  
  <p>ItemsResource</p>
  
  <pre><code>@Path("items")
  public class ItemsResource extends V1BaseResource {
  
      @GET
      public Response getItems() ...
  }
  </code></pre>
  
  <p>Unfortunately, the <code>@Path</code> annotation of the actual resources <em>overwrites the path</em>, not <em>adds to it</em>.</p>
  
  <p>Is this possible (with out the use of <a href="https://jersey.java.net/documentation/latest/jaxrs-resources.html#d0e2549" rel="nofollow noreferrer">sub-resource locators</a>)?</p>