6.5. 融合 BOM 文件
要将 BOM 文件合并到 Maven 项目中,请在项目的 pom.xml 文件中指定一个 dependencyManagement 元素(或者在父 POM 文件中,如 Spring Boot 2 的示例中所示:
Spring Boot 2 BOM
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project ...>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- configure the versions you want to use here -->
<fuse.version>7.11.1.fuse-sb2-7_11_1-00022-redhat-00002</fuse.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.redhat-fuse</groupId>
<artifactId>fuse-springboot-bom</artifactId>
<version>${fuse.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
</project>
在使用依赖关系管理机制指定 BOM 后,可以在不指定工件版本的情况下将 Maven 依赖项添加到 POM 中。例如,要为 camel-hystrix 组件添加一个依赖项,您要将以下 XML 片段添加到 POM 中的 dependencies 元素中:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-hystrix-starter</artifactId>
</dependency>
请注意,Camel 工件 ID 如何通过 -starter 后缀是:将 Camel Hystrix 组件指定为 camel-hystrix-starter,而非 camel-hystrix。Camel 启动程序组件以针对 Spring Boot 环境进行优化的方式打包。