title: Jersey 2 + Spring 4 without web.xml/applicationContext.xml
body: <p>I have 2 Maven projects:</p>
  
  <ul>
  <li>project1 that contains my entities/services/DAOs, with a Java Spring (4.2.4) config (no XML)</li>
  <li>project2 that is my RESTful API using Jersey (2.22.1), that contains the resources (controllers), Java configuration (extending <code>ResourceConfig</code>, no web.xml) </li>
  </ul>
  
  <p>I would like to inject my services in my Jersey resources, here is what I did:</p>
  
  <ol>
  <li>I added the Maven dependency to project1 in project2</li>
  <li>I added the dependency jersey-spring3 to project2</li>
  </ol>
  
  <p>I didn't change anything in my Jersey config class.  </p>
  
  <p>I run jetty (Maven plugin, no <code>public static void main</code> or any class to run the server).<br>
  First attempt: applicationContext.xml was required.<br>
  Second attempt: after adding an empty applicationContext.xml (to project2), my services are not found.<br>
  Third attempt: after adding <code>&lt;context:component-scan base-package="com.xxx.project1"/&gt;</code> to applicationContext.xml (package where my project1 Java Spring config lives), services are injected.  </p>
  
  <p><strong>My question is how to get rid of the applicationContext.xml file?</strong><br>
  I would like my Spring config from project1 to be detected automatically...  </p>
  
  <p>Some code:<br>
  The Spring configuration</p>
  
  <pre><code>@Configuration
  @ComponentScan("com.xxx.project1.service")
  public class SpringConfig {
  
  }
  </code></pre>
  
  <p>The Jersey configuration</p>
  
  <pre><code>@ApplicationPath("/v1")
  public class Application extends ResourceConfig {
  
      public Application() {
          packages("com.xxx.project2.filter",
          "com.xxx.project2.resource");
          register(RolesAllowedDynamicFeature.class);
      }
  }
  </code></pre>