2

I am using spring-boot 2.0.3.RELEASE. When I am clicking on "show Effective POM" option by using IntelliJ IDEA, it loads Effective POM. And there I can see a few dependencies that my client don't want to have at there side.

Is there any way to tell Maven not to include these dependencies? How can we exclude dependencies from effective poms?

Ashish Pancholi
  • 4,569
  • 13
  • 50
  • 88

1 Answers1

0

Maven provides a way to exclude dependencies with the exclude tag

Here is an example taken from the documentation website https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

   <dependencies>
    <dependency>
      <groupId>sample.ProjectA</groupId>
      <artifactId>Project-A</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>  <!-- declare the exclusion here -->
          <groupId>sample.ProjectB</groupId>
          <artifactId>Project-B</artifactId>
        </exclusion>
      </exclusions> 
    </dependency>
  </dependencies>

The idea is to locate parent dependencie from where you are getting deps you don't want and add an exclusion tag.

If they are needed in runtime you can specify the scope to provided

<dependency>
      <groupId>sample.ProjectA</groupId>
      <artifactId>Project-A</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
</dependency>

That will tell maven to use the deps to compile but not no include them in the target package, and they will be provided in the production environment by the JVM executing the code.

Hope this helps

Francisco Valle
  • 613
  • 10
  • 10