title: Override jersey resource with guice
body: <p>I'm looking for a method to override jersey resources bounded with guice in GuiceServletContextListener. My code, which I'm trying to get working:</p>
  
  <pre><code>//Define Jersey resource interface
  @Path("/books/{key}")
  public interface BookDocument {
  
      public BookDAO getDao();
  
      public void setDao(BookDAO dao);
  }
  
  //Define default implementation
  public class BookImpl implements Book {
  
      @Override
      public BookDAO getDao() {
          return dao;
      }
  
      @Inject
      @Override
      public void setDao(BookDAO dao) {
          this.dao = dao;
      }
  }
  
  //User wants to inject his implementation, so he define it
  public class BookUserImpl implements Book {
  
      @Override
      public BookDAO getDao() {
          return dao;
      }
  
      @Inject
      @Override
      public void setDao(BookDAO dao) {
          this.dao = dao;
      }
  }
  
  //Inject default implementation of resource
  public class ApplicationResourcesModule extends AbstractModule
  {
      @Override
      protected void configure()
      {
          bind(Book).to(BookImpl);
      }
  }
  
  //But user wants to inject his implementation, so he bind it in users AbstractModule
  public class ApplicationResourcesModuleUser extends AbstractModule
  {
      @Override
      protected void configure()
      {
          bind(Book).to(BookUserImpl);
      }
  }
  
  //Bind all resources
  public class JerseyGuiceConfig extends GuiceServletContextListener
  {
      @Override
      protected Injector getInjector()
      {
          //Override default binding by user bindings.
          return Guice.createInjector(Modules.override(new ApplicationResourcesModule()).with(new ApplicationResourcesModuleUser()), new JerseyServletModule());
      }
  }
  </code></pre>
  
  <p>But unfortunately this doesn't work, while I can't bind jersey resources in guice like interface to implementation, only <code>bind(BookImpl.class)</code> work's. But such binding is impossible to overwrite. If I try to override <code>bind(BookImpl.class)</code> with <code>bind(BookUserImpl.class)</code> I get an error <code>Conflicting URI templates. The URI template /books/{key} for root resource class.</code> while @Path should be unique. So is there any solution for my use case?</p>