Maven excluded jar of different versions with the same name in the project

Source: Internet
Author: User

Today, I suddenly found that the web project package had 200 MB + of exe, and thought it should not be so big. So I checked and found that there were more than 130 referenced jar files, A lot of jar files with the same name but different versions are found. For example, there are two jar files with commons-httpclient, 3.0 and 3.1. This directly leads to a lot of repeated jar files under lib, and the size of the installer will naturally go up.

Open POM. run the mvn dependency: tree Command to view the dependency tree structure. Two jar files depend on the commons-httpclient jar, but the two dependent versions are different, so maven adds both versions.

The solution is to configure the jar file to be excluded from dependency through exclusions. Example:

Org. codehaus. xfire-all 1.2.6 org. springframework spring

 

In this way, the spring dependency in xfire is excluded. Similarly, you can see which jar files are repeatedly dependent Based on the maven dependency tree, and then exclude repeated items through exclusions.

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.