Sometimes there is requirement to make a dependency optional or exclude that particular dependency. We can achieve it by manually deleting it from .m2 folder . There is another efficient way to do it through pom.xml file by using particular tags. Lets see how :
1) To make a dependency Optional :
2) To exclude a particular dependency :
1) To make a dependency Optional :
- <dependencies>
- <dependency>
- <groupId>org.seleniumhq</groupId>
- <artifactId>selenium</artifactId>
- <version>1.0</version>
- <optional>true</optional> <!-- we set value as true or false only -->
- </dependency>
- </dependencies>
Here we are simply using a optional tag in particular dependency and set the optional tag either as true or false.2) To exclude a particular dependency :
- <exclusions>
- <exclusion>
- <groupId>org.seleniumhq</groupId>
- <artifactId>selenium</artifactId>
- </exclusion>
- </exclusions>
Here we can add the dependencies that can be excluded from the dependency by using this
No comments:
Post a Comment