title: Exclude a class from maven dependency
body: <p>I am using <a href="https://github.com/jersey/jersey/tree/master/ext/spring3" rel="nofollow">org.glassfish.jersey.ext:jersey-spring3</a> for Injecting Spring Beans into Jersey JAX-RS resource class. Bean injection works fine except for this jar also contains <a href="https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/server/spring/SpringWebApplicationInitializer.html" rel="nofollow">SpringWebApplicationInitializer</a> class which directly interferes with my own Custom WebApplicationInitializer. For testing purpose, I forcibly removed <a href="https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/server/spring/SpringWebApplicationInitializer.html" rel="nofollow">SpringWebApplicationInitializer</a> from initializing in <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/SpringServletContainerInitializer.html" rel="nofollow">SpringServletContainerInitializer</a> in Debug mode and my app runs fine.</p>
  
  <p>I also tried maven-shade-plugin with following configuration</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.4.1&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;shade&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;filters&gt;
                      &lt;filter&gt;
                          &lt;artifact&gt;org.glassfish.jersey.ext:jersey-spring3&lt;/artifact&gt;
                          &lt;excludes&gt;
                              &lt;exclude&gt;org/glassfish/jersey/server/spring/SpringWebApplicationInitializer.class&lt;/exclude&gt;
                          &lt;/excludes&gt;
                      &lt;/filter&gt;
                  &lt;/filters&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>This plugins copies both jars and classes to WAR file. SO even though SpringWebApplicationInitializer.class was removed, original jar (which still contains SpringWebApplicationInitializer.class) was copied and SpringServletContainerInitializer is still picking up SpringWebApplicationInitializer class.</p>