问题描述
我不明白 bom 对象的目的是什么?我正在使用 Spring 3.2.8 版本和 JBoss 服务器,那么我需要使用哪个 bom 依赖项?当我在 pom.xml 中提到以下依赖项时:
I am not understanding what is the purpose of bom object? and I am working on Spring 3.2.8 version and with JBoss server, so which bom dependency I need to use? When I mention the following dependency in pom.xml:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
jar 文件是否会下载到我的 Maven 依赖项中?
Does the jar file gets downloaded into my Maven Dependencies?
推荐答案
bom对象的作用是什么?
Maven 父子关系对于在一个地方管理多个项目的依赖关系非常方便.但是,Maven 项目只能有一个(直接)父级.因此引入了依赖项管理的导入,以允许使用多个项目来管理您的依赖项.通过导入,您可以像这样定义单个依赖项并管理多个依赖项 - 方便!尽管您可以导入任何项目,但 BOM 是一个特殊项目,旨在用于此类导入.通常一个 BOM 项目除了 dependencyManagement
部分之外几乎没有定义,并且不会有任何无关的依赖项,以免对您的主项目造成太大影响.
What is the purpose of bom object?
Maven parent-child relationship is very handy for managing dependencies of multiple projects in a single place. However, Maven projects can have only one (direct) parent. So imports were introduced for dependency management to allow using several projects for managing your dependencies. With an import you can define a single dependency like this and get multiple dependencies managed - handy! Although you could import any project, BOM is a special project designed to be used for imports like this. Usually a BOM project will have very little defined besides dependencyManagement
section, and will not have any unrelated dependencies, to avoid affecting your main project too much.
BOM 不是必需的,您也不需要使用.相反,您可以自己在 dependencyManagement 部分中定义所有托管依赖项.这些可以包括 Spring、JBoss 和任何其他依赖项.然而,BOM 为您大大简化了这一过程.您可以根据需要添加任意数量的 BOM,因此请同时添加!但正如@Jesper 提到的,不要忘记使用正确的版本.使用多个 BOM 时,如果它们都引用公共依赖项,它们的顺序将很重要.
BOM is not a requirement, you don't need to use either. Instead, you could define all managed dependencies in dependencyManagement section yourself. These can include Spring, JBoss and any other dependencies. BOM, however, simplifies this for you significantly. You can add as many BOMs as you want, so add both! But as @Jesper mentions, don't forget to use correct versions. When using multiple BOMs their order will matter if they both reference a common dependency.
注意 BOM 是 <type>pom</type>
,而不是默认的 jar
.所以没有要下载的jar.Maven 将下载并读取单个 pom.xml 文件.
Notice BOM is <type>pom</type>
, not the default jar
. So there's no jar to be downloaded. A single pom.xml file will be downloaded and read by Maven.
这篇关于Maven BOM [Bill Of Materials] 依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!