How to exclude jars generated by maven war plugin

Because of transitive dependencies, my wars are getting populated by xml-apis, xerces jars. I tried following the instructions on the reference page for maven-war-plugin but it is not working.

<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-war-pluginartifactId>
    <configuration>
      <packagingExcludes>WEB-INF/lib/xalan-2.6.0.jar,WEB-INF/lib/xercesImpl-2.6.2.jar,WEB-INF/lib/xml-apis-1.0.b2.jar,WEB-INF/lib/xmlParserAPIs-2.6.2.jarpackagingExcludes>
      <webXml>${basedir}/src/main/webapp/WEB-INF/web.xmlwebXml>
      <warName>project1warName>
      <warSourceDirectory>src/main/webappwarSourceDirectory>
    configuration>
plugin>

What am I doing wrong ? If it matters, I discovered that the maven-war-plugin I'm using is at version 2.1-alpha-1



You can mark these dependencies as provided:

<dependency>
  <groupId>xercesgroupId>
  <artifactId>xercesartifactId>
  <version>2.4.0version>
  <scope>providedscope>
dependency>

This way the maven will add them to the compilation classpath, but will not package them. It is assumed they exist in your servlet container.

See more about maven scopes here under "scope"

Edit If you want to remove classes added via transitive dependencies you can exclude them from the dependency like this:

<dependency>
        <groupId>org.springframeworkgroupId>
        <artifactId>springartifactId>
        <version>2.5.6version>
        <exclusions>
                <exclusion>
                        <groupId>commons-logginggroupId>
                        <artifactId>commons-loggingartifactId>
                exclusion>
        exclusions>
dependency>

你可能感兴趣的:(maven,maven)