Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to resolve jar conflicts in Maven projects

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to resolve the jar conflict in the Maven project". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to resolve the jar conflict in the Maven project.

Problem analysis

In order to solve this problem, the first thing we need to make clear is several major principles of maven: first, dependency transfer assumes that Project A depends on B, B and C, then A will also rely on C.

Graph LRA (Project A)-- dependency-- > B (Project B) B-- dependency-- > C (Project C) A-- dependency-- > C

Declaration priority principle assumes that version An and version B of the same jar package are declared successively in the maven project, then maven will use version A

Graph LRA (declare version A)-- > B (declare version B) O ((maven))-- use-- > AO-- does not use-- > B

Third, the principle of nearest path priority assumes that the project directly depends on AMagi A, depends on Bmai B on C1, and that the project directly depends on DPerry D on C2, then the project will use C2.

Graph LRO ((Project))-- Direct dependence-- > A (A) Amure-> B (B) Bmuri-> C1 (C1) Omure-Direct dependence-- > D (D) Dmuri-> C2 (C2) Omure-use-- > C2

When different versions of jar are introduced into the project at the same time, the problem of relying on arbitration appears. To solve the problem of relying on arbitration, we should make full use of the three principles of maven dependence.

Solution 1. Version exclusion

Use tags to exclude unused jar package version types

Commons-httpclient commons-httpclient 3.1 commons-logging commons-logging

This method can be easily implemented through the plug-in of IDEA.

II. Version locking

Use tags to lock fixed versions of jar packages

Com.alibaba.boot dubbo-spring-boot-starter 0.2.0 III. Direct introduction

Using the principle of nearest path first, when other dependent jar indirectly depends on a version of jar that is not what we want, we can directly introduce our desired version of jar package into the project.

Thank you for your reading, the above is the content of "how to resolve the jar conflict in the Maven project". After the study of this article, I believe you have a deeper understanding of how to resolve the jar conflict in the Maven project. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report