如何与 Maven 一起使用 BOM 文件?

我在互联网上做了相当多的研究,我没有找到任何简单的解释如何处理 BOM文件与 Maven。

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

请帮帮我。

46758 次浏览

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.

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

A practical example:

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>

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>