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.8.0.fuse-sb2-780038-redhat-00001</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 后,可以在 POM 中添加 Maven 依赖项,而不指定 工件版本。例如,要为 camel-hystrix 组件添加依赖项,您要将以下 XML 片段添加到 POM 中的 dependencies 元素中:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-hystrix-starter</artifactId>
</dependency>
请注意,如何将 Camel 工件 ID 指定为:start -starter 后缀是 in,您可以将 Camel Hystrix 组件指定为 camel-hystrix-starter,而不是 camel-hystrix。Camel 初学者组件以针对 Spring Boot 环境优化的方式打包。