How to exclude jars generated by maven war plugin?

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”

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

Leave a Comment