Oct 10, 2018

[HDGEM] How to exclude dependency in Apache Maven

Using Apache Maven, dependencies can be globally excluded in your project like so:
  1. <dependencies>
  2. <dependency>
  3. <groupId>log4j</groupId>
  4. <artifactId>log4j</artifactId>
  5. <version>1.2.17</version>
  6. <scope>provided</scope>
  7. </dependency>
  8. </dependencies>
Dependencies can be explicitly excluded for specific dependencies as well. For example, to use a project with Log4j 2 instead of Log4j 1.x:
  1. <dependencies>
  2. <dependency>
  3. <groupId>com.example</groupId>
  4. <artifactId>example-project</artifactId>
  5. <version>1.0</version>
  6. <exclusions>
  7. <exclusion>
  8. <groupId>log4j</groupId>
  9. <artifactId>log4j</artifactId>
  10. </exclusion>
  11. <exclusion>
  12. <groupId>org.slf4j</groupId>
  13. <artifactId>slf4j-log4j12</artifactId>
  14. </exclusion>
  15. </exclusions>
  16. </dependency>
  17. <dependency>
  18. <groupId>org.apache.logging.log4j</groupId>
  19. <artifactId>log4j-core</artifactId>
  20. <version>2.8</version>
  21. </dependency>
  22. <dependency>
  23. <groupId>org.apache.logging.log4j</groupId>
  24. <artifactId>log4j-slf4j-impl</artifactId>
  25. <version>2.8</version>
  26. </dependency>
  27. <dependency>
  28. <groupId>org.apache.logging.log4j</groupId>
  29. <artifactId>log4j-1.2-api</artifactId>
  30. <version>2.8</version>
  31. </dependency>
  32. </dependencies>


--
Posted By Blogger to HDGEM at 2/22/2017 11:32:00 AM