6.2. アプリケーションでの BOM の指定
アプリケーションの pom.xml
ファイルに特定の BOM をインポートすると、すべてのアプリケーション依存関係を 1 つの場所で追跡できます。
Maven BOM インポートの欠点の 1 つは、< pluginManagement> のレベルの設定を処理しないことです
。Thorntail Maven プラグインを使用する場合は、使用するプラグインのバージョンを指定する必要があります。
pom.xml
ファイルで使用するプロパティーにより、プラグインの使用が BOM インポートで対象とする Thorntail のリリースと一致することを簡単に確認できます。
<plugins> <plugin> <groupId>io.thorntail</groupId> <artifactId>thorntail-maven-plugin</artifactId> <version>${version.thorntail}</version> ... </plugin> </plugins>
前提条件
-
アプリケーションが Maven ベースのプロジェクトとして
pom.xml
ファイルがある。
手順
pom.xml
にbom
アーティファクトを含めます。pom.xml
のプロパティーで現行バージョンの Thorntail を追跡することが推奨されます。<properties> <version.thorntail>2.7.3.Final-redhat-00001</version.thorntail> </properties>
<
dependencyManagement>
セクションに BOM をインポートします。<type>pom</type> および <
;scope>import</scope> を指定し
ます。<dependencyManagement> <dependencies> <dependency> <groupId>io.thorntail</groupId> <artifactId>bom</artifactId> <version>${version.thorntail}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
上記の例では、
bom
アーティファクトがインポートされ、安定した分のみが利用可能になります。<
dependencyManagement
> セクションに選択した BOM を含めると、以下が必要になります。- その後、Thorntail アーティファクトに提供され た バージョン管理。
-
アプリケーションの
pom.xml
ファイルの編集時に既知のアーティファクトを自動的にインストールするために IDE へのサポートが提供されました。
Thorntail 依存関係を含めます。
<
dependencyManagement
> セクションに Thorntail BOM をインポートしていても、アプリケーションには Thorntail アーティファクトの依存関係はありません。アプリケーションの機能に基づいて Thorntail アーティファクトの依存関係を含めるには、<
dependency> 要素として関連する
アーティファクトを入力します。注記<
dependencyManagement> でインポートされた BOM がそれを処理するため、アーティファクトのバージョンを指定する必要は
ありません。<dependencies> <dependency> <groupId>io.thorntail</groupId> <artifactId>jaxrs</artifactId> </dependency> <dependency> <groupId>io.thorntail</groupId> <artifactId>datasources</artifactId> </dependency> </dependencies>
上記の例では、
jaxrs
およびデータソース
の分解に対する明示的な依存関係が含まれており、これはundertow
などの推移的組み込みを提供します。