Maven project, removing unwanted dependencies in the jar package

Source: Internet
Author: User

Explanation: That is, the project to use a certain A.jar package, through the introduction of MAVEN, and automatically import the package that the jar depends on, there is a problem, if the A.jar package depends on B.jar 1.0 version of this project, but my project has B.jar this project 2.0 version, here will The solution to this conflict is to remove the dependency of the A.jar package on the 1.0 version of the B.jar project, so that the project uses the packages I already have.

Recently set up a springmvc4.x maven environment, because to use the Webserice, intends to integrate Jersey to do, in the import Jersey-spring.jar, there is such a problem, I use the Jersey-spring1.81.jar version, the project relies on the SPR Ing3, So add Jersey-spring1.81.jar to maven or it happens that because it relies on spring3.x, it automatically imports the spring3.x jar and automatically deletes my spring4.x package, causing the spring4.x to not build at all, but I have There is a 4.x package, completely do not need it to automatically import 3 of the package to remove 4 of the package AH

Resolution version:

Remove the original dependency of Jersey-spring1.81.jar, so that it does not automatically go to the Spring3 package, but the use of my existing SPRING4 package,

Similarly, a similar problem can be solved in the future, the rule is to import a package to remove the original dependency of the label, the label is written to remove the ID and version of the package.

Paste the Solution code:

---------------------------------------------------------------------------

<dependency><groupid>com.sun.jersey.contribs</groupid><artifactid>jersey-spring</                artifactid><version>1.18.1</version><!--Remove your own spring version-<exclusions> <exclusion> <groupId>org.springframework</groupId> <artifact                    Id>spring-aop</artifactid> </exclusion> <exclusion>                <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </exclusion> <exclusion> &LT;GROUPID&GT;ORG.SPRINGFRAMEWORK&L                T;/groupid> <artifactId>spring-beans</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> < Artifactid>spring-core</artifactid> </exclusion> <exclusion> <artifactid>spring-web&             Lt;/artifactid> <groupId>org.springframework</groupId> </exclusion> </exclusions></dependency>

Maven project, removing unwanted dependencies in jar packages

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.