

Maven BOM
source link: https://sergiuoltean.com/2018/11/29/maven-bom/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Maven BOM
BOM stands for Bill of Materials. Basically we can use it to store in one place all the dependencies with their versions. It’s useful in the case microservices are used to make sure same versions are used everywhere. Of course this is not necessarily a requirement for microservices, as you have the choice to build it how you want. No need to use the same libraries everywhere. But the developer in us screams for consistency. If you’re familiar with spring boot, you may check the way they are doing dependency management with bom.
We can import it in two ways:
- as dependency
- as parent pom
Considering this bom (which is just a pom file)
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
modelVersion
>4.0.0</
modelVersion
>
<
groupId
>com.sergiuoltean.test</
groupId
>
<
artifactId
>bom</
artifactId
>
<
version
>1.0-SNAPSHOT</
version
>
<
packaging
>pom</
packaging
>
<
properties
>
<
project.build.sourceEncoding
>UTF-8</
project.build.sourceEncoding
>
<
project.reporting.outputEncoding
>UTF-8</
project.reporting.outputEncoding
>
<
java.version
>11</
java.version
>
<
docker-maven-plugin.version
>0.27.1</
docker-maven-plugin.version
>
<
spring-cloud.version
>Greenwich.M1</
spring-cloud.version
>
<
jaxb-api.version
>2.3.0</
jaxb-api.version
>
<
jjwt.version
>0.10.5</
jjwt.version
>
</
properties
>
<
parent
>
<
groupId
>org.springframework.boot</
groupId
>
<
artifactId
>spring-boot-starter-parent</
artifactId
>
<
version
>2.1.0.RELEASE</
version
>
<
relativePath
/>
<!-- lookup parent from repository -->
</
parent
>
<
dependencyManagement
>
<
dependencies
>
<
dependency
>
<
groupId
>org.springframework.cloud</
groupId
>
<
artifactId
>spring-cloud-dependencies</
artifactId
>
<
version
>${spring-cloud.version}</
version
>
<
type
>pom</
type
>
<
scope
>import</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>io.jsonwebtoken</
groupId
>
<
artifactId
>jjwt-api</
artifactId
>
<
version
>${jjwt.version}</
version
>
</
dependency
>
<
dependency
>
<
groupId
>io.jsonwebtoken</
groupId
>
<
artifactId
>jjwt-impl</
artifactId
>
<
version
>${jjwt.version}</
version
>
</
dependency
>
<
dependency
>
<
groupId
>io.jsonwebtoken</
groupId
>
<
artifactId
>jjwt-jackson</
artifactId
>
<
version
>${jjwt.version}</
version
>
</
dependency
>
<
dependency
>
<
groupId
>javax.xml.bind</
groupId
>
<
artifactId
>jaxb-api</
artifactId
>
<
version
>${jaxb-api.version}</
version
>
</
dependency
>
</
dependencies
>
</
dependencyManagement
>
<
repositories
>
<
repository
>
<
id
>spring-milestones</
id
>
<
name
>Spring Milestones</
name
>
<
snapshots
>
<
enabled
>false</
enabled
>
</
snapshots
>
</
repository
>
</
repositories
>
</
project
>
When importing as parent pom you will get both plugins and dependencies defined only in one place.
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
artifactId
>commons</
artifactId
>
<
packaging
>pom</
packaging
>
<
version
>1.0-SNAPSHOT</
version
>
<
parent
>
<
groupId
>com.sergiuoltean.test</
groupId
>
<
artifactId
>bom</
artifactId
>
<
version
>1.0-SNAPSHOT</
version
>
<
relativePath
/>
</
parent
>
</
project
>
Ideally this should be placed in a commons module/repo and all services should import it.
Recommend
-
31
-
17
字节顺序标记(byte order mark),是位于码点U+FEFF的统一码字符的名称。当以UTF-16或UTF-32来将UCS/统一码字符所组成的字符串编码时,这个字符被用来标示其字节序。它常被用来当做标示文件是以UTF-8、UTF-16或UTF-32编码的标记。 不同编码的字...
-
9
欢迎转载,请支持原创,保留原文链接:blog.ilibrary.me UTF-8 BOM UTF-8 编码的文件可以分为no BOM 和 BOM两种格式。
-
12
BOM PHP文件迁移到LINUX服务器,BOM在捣乱
-
15
OSS The Curious Case of the JSON BOM Jimmy Bogard...
-
6
BOM头导致shell执行失败 调用shell时失败,提示未找到命令,如下图所示:
-
6
Linux下utf-8 BOM 文件的检查与删除 作者: JavasBoy 分类: Bash,
-
12
万恶的BOM: 与 \ufeff 2017-07-24 Monday 最近在搞一个 Sass 文件的编译插件,主要使用 node-sass 来进行编译,在这过程中遇到一个蛮坑的小问题。 在不压缩的情况下使用 node-sass 进...
-
5
UTF-8编码中BOM的检测与删除 浏览:3639次 出处信息 所谓BOM,全称是
-
3
制定组织内 Maven BOM 的一些规范2022-09-03
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK