Maven exclusion resolves version conflicts in Maven delivery dependencies

Source: Internet
Author: User

Delivery dependency is one of the most distinctive and convenient features of Maven, and can save a lot of configuration. such as a dependent b,b dependency C default A will also depend on C. But there are also pitfalls, such as version conflicts. Of course, MAVEN also considers the solution, you can use exclusions to exclude the corresponding repeat dependency.


But we also have a serious problem, and that is, how do I know which package is the transitive dependency of the conflict? What should we do then? Of course, MAVEN will also have a solution.

First, you add the Maven-project-info-reports-plugin plugin to the pom.xml.

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>
Maven-project-info-reports-plugin
</artifactId>
</plugin>
</reporting>

Then execute: mvn project-info-reports:dependencies. Build the reports that your project relies on so you can find dependencies on your version conflicts in your reports. If a outofmemoryerror error occurs, add parameters to the system environment maven_opts=-xmx512m

Finally, add exclusions in the corresponding dependency to exclude the related transitive dependencies.

Cases:

<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
<exclusions>
<exclusion>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>

Maven exclusion resolves version conflicts in Maven delivery dependencies

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.