How to Disable Dependency Injection in Jersey 2?
<p>I'm new to creating REST web services with Jersey 2.  I was able to get a few simple cases going now I'm moving on to "real" work.</p>

<p>I create my own instances of <code>ResourceConfig</code> and populate the <code>ResourceConfig</code> instances with instances of the REST controller returned by Guice:</p>

<pre><code>&lt;!-- language: lang-java --&gt;
final ResourceConfig rc = new ResourceConfig();

//register an *instance* of a REST controller
rc.register(injector.getInstance(MyRestController.class));
</code></pre>

<p>Note that since these REST controller instances were provided by Guice, the instances are populated with all necessary dependencies that are marked with the <code>@Inject</code> annotation.</p>

<p>However, when I run the above code to bootstrap Jersey, I see an error like the following:</p>

<pre><code>org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(....
</code></pre>

<p>Apparently what is happening is that Jersey is <strong>also</strong> trying to resolve the <code>@Inject</code> dependencies on the REST controller instance, because it sees the same <code>@Inject</code> annotations that Guice does.  </p>

<p>I don't want Jersey to do any dependency injection.  I think there are bridges from Jersey to Guice, but based on program requirements that I can't show here, I need to create the REST controller instances myself and ask the Guice <code>Injector</code> for them.</p>

<p><strong>My question:</strong>  How can I disable the dependency injection in Jersey?</p>

<p>I'm currently using the <code>javax.inject.Inject</code> annotation.  Maybe I can use the <code>com.google.inject.Inject</code> annotation instead, thinking that Jersey won't be looking for these annotations.  But still, I would rather just turn off dependency injection in Jersey.  How can I do that?</p>

<p>Thank you!!</p>