Maven BOM [物料清单]依赖性 [英] Maven BOM [Bill Of Materials] Dependency

查看:146
本文介绍了Maven BOM [物料清单]依赖性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白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 [物料清单]依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆