Java – 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.


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

Best Solution

You can mark these dependencies as provided:


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:


(taken from this answer)

See more here