如何在 Maven 中使用 BOM 文件? [英] How to use BOM file with Maven?

查看:32
本文介绍了如何在 Maven 中使用 BOM 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上做了大量研究,但没有找到任何简单的解释如何使用 Maven 处理 BOM 文件.

I have done considerable research in internet and I haven't found any easy explanation what to do with BOM files with Maven.

问题是我使用 JBoss 7.1.1,我想在 pom.xml 中包含所有 JBoss 客户端 jar.JBoss 有一个手册说我应该使用 BOM 文件,但我不知道如何在我的 pom.xml 中使用它.

The problem is that I use JBoss 7.1.1 and I want to include all JBoss client jars in pom.xml. JBoss has a manual that says that I should use BOM files, but I don't know how to use it in my pom.xml.

请帮忙.

推荐答案

bom 是所谓的材料清单 - 它捆绑了几个依赖项以确保版本将一起工作.JBoss 的许多项目都有 boms,包括 ArquillianJBoss AS 本身.

A bom is a so called bill of materials - it bundles several dependencies to assure that the versions will work together. JBoss has boms for many of it's projects, including Arquillian and the JBoss AS itself.

bom用法的解释"noreferrer">maven 文档 - 它隐藏在下面.

There is an explanation of the bom usage in the maven docs - it is hidden well below.

一个实际例子:

您将 bom 包含在您的 pom 中,如下所示:

You include the bom into your pom like this:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.bom</groupId>
            <artifactId>jboss-javaee-6.0-with-tools</artifactId>
            <version>${javaee6.with.tools.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement> 

那么你就不必指定依赖的版本属性,如果它在bom中定义如下:

Then you do not have to specify the version attribute of a dependency, if it is defined in the bom like this:

<dependency>
    <groupId>javax.enterprise</groupId>
    <artifactId>cdi-api</artifactId>
    <scope>provided</scope>
</dependency>

这篇关于如何在 Maven 中使用 BOM 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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