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 use Maven's BOM to manage version dependencies in microservices

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you "how to use Maven's BOM to manage version dependencies in microservices", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to use Maven's BOM to manage version dependencies in microservices".

Introduction to BOM

BOM (Bill of Materials) is a function provided by Maven. By defining a set of compatible jar package versions, you only need to rely on the BOM file to use the dependent jar package you need without specifying the version number. The maintainer of BOM is responsible for version upgrades and ensures compatibility between versions of jar packages defined in BOM.

Why use BOM

In addition to using BOM to make it easier for users not to specify a version number when declaring dependent clients, the main reason is that dependency conflicts can be resolved, such as considering the following dependency scenarios:

Project A depends on Project B 2.1 and Project C 1.2: project B 2.1 depends on Project D 1.1; Project C 1.2 depends on Project D 1.3

In this case, project A's dependence on project D conflicts, and according to maven dependency mediation rules, what may eventually take effect is that project A will rely on project D1.1 (proximity principle, depending on the path and dependency sequence, and related to the Maven version).

In this case, because project C relies on version 1.3 of project D, but it is indeed version 1.1 at run time, it is easy to cause problems at run time, such as NoSuchMethodError, ClassNotFoundException, etc.

How to define BOM

BOM is essentially an ordinary POM file, but the difference is that this is the only part that is in effect for the user. You only need to define the released client version:

4.0.0 com.ydj.qd inf-bom 1.0 pom inf-bom third-party jar package unified management UTF-8 UTF-8 1.8 4.3.15.RELEASE com.alibaba druid 1.1.12 com.aliyun.mns aliyun-sdk-mns 1.1.8 jar-with-dependencies com.alibaba fastjson 1.2.29 org.apache.commons commons-lang3 3.3.2 commons-collections commons-collections 3.2.2 org.apache. Commons commons-collections4 4.1 commons-beanutils commons-beanutils 1.9.1 com.google.guava guava 27.0.1-jre com.google.code.gson gson 2.8.5 joda-time joda-time 2.7 org.projectlombok lombok 1.14.4 maven-releases maven-releases http://mvn.ydj.com/repository/maven-releases/ maven-snapshots maven-snapshots http://mvn.ydj.com/repository/maven-snapshots/

Project usage

Add the following in the first place below the node in your project's main pom.xml file:

Com.jlcx.qd inf-bom ${version} pom import...

Introduce the following under the nodes in the pom.xml file where you need to use the relevant JAR package:

... Com.google.guava guava commons-collections commons-collections....

If you need to use a version of the jar package that is different from the version maintained in the current bom, you can add an override, such as:

... Com.google.guava guava commons-collections commons-collections 3.2.1....

The above is all the contents of the article "how to use Maven's BOM to manage version dependencies in microservices". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report