title: Integrating Jersey 2 and Spring with Java Based Configuration
body: <p>I am using Jersey 2.10 and jersey-spring3 and Spring 4.
  I want to achieve DI(basically services) in jersey resources as well as in other places and want to create Spring Beans through Java Configuration.</p>
  
  <p>Currently,I am not able to find out any way to do this.
  Any idea how to do this?</p>
  
  <p>my web.xml looks like this</p>
  
  <pre><code>&lt;web-app&gt;
      &lt;display-name&gt;Restful Web Application&lt;/display-name&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;
               org.glassfish.jersey.servlet.ServletContainer 
  
          &lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;
                  jersey.config.server.provider.packages
              &lt;/param-name&gt;
              &lt;param-value&gt;com.xyz&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/application-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>