How to remove unwanted jars included in the lib using maven

Maven automatically resolves dependencies transitively, i.e. it adds the dependencies of your dependencies to the WAR as well.

This way Maven makes sure that you do not run into ClassNotFound exceptions because viewservlets is trying to call something that does not exist.

Of course, it may be the case that some of those dependencies are not really called at runtime. If you are sure that a given artifact is never called, you can exclude it with an exclusion. But it is generally hard to determine that and it is probably not worth the effort.

EDIT: an example

<dependency>
  <groupId>org.eclipse.birt.runtime</groupId>
  <artifactId>viewservlets</artifactId>
  <version>4.4.1</version>
  <exclusions>
     <exclusion>
        <groupId>*</groupId>
        <artifactId>*</artifactId>
     </exclusion>
   </exclusions>
</dependency>
<dependency>
  <groupId>org.something</groupId>
  <artifactId>otherdependency</artifactId>
  <version>1.2.3</version>
</dependency>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top