配置相依關係 POM 檔案,使其模擬特定 WebSphere 執行時期環境的類別路徑
您可以使用「目標專案物件模型 (POM)」檔案作為 Maven 相依關係。這些依賴關係會模擬 WebSphere 執行時期環境的類別路徑, 來編譯 Java EE 和 OSGi 應用程式。
關於這項作業
您必須根據您正在使用的 WebSphere Application Server Liberty 或傳統版的版本,以不同方式來配置目標 POM 檔案。
程序
- 若為 WebSphere Application Server Liberty 8.5.5.8 版和更新版本,請完成下列步驟:
- 選擇 Maven 相依關係之下列其中一個 Snippet 的適用版本。
下列 Snippet 是 Maven Central 中之 ci.maven.tools GitHub 儲存庫的一部分。
- liberty-target
此相依關係聚集了所有 WebSphere Application Server Liberty API、SPI、 建議的 Java 規格相依關係,以及協力廠商實作相依關係。
<dependency> <groupId>net.wasdev.maven.tools.targets</groupId> <artifactId>liberty-target</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>- liberty-apis
此相依關係包含 WebSphere Application Server Liberty API 相依關係。此相依關係適用於 Liberty 安裝架構 dev/api/ibm/ 目錄中的所有 API 程式庫。
<dependency> <groupId>net.wasdev.maven.tools.targets</groupId> <artifactId>liberty-apis</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>- liberty-spis
此相依關係包含 WebSphere Application Server Liberty SPI 相依關係。此相依關係適用於 Liberty 安裝架構 dev/spi/ibm/ 目錄中的所有 SPI 程式庫。
<dependency> <groupId>net.wasdev.maven.tools.targets</groupId> <artifactId>liberty-spis</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>- java-specs
此相依關係包含 Java 規格相依關係。此相依關係可適用於 Liberty 安裝架構 dev/api/ibm/ 和 dev/spi/ibm/ 目錄中所有建議的 Java 規格程式庫。
<dependency> <groupId>net.wasdev.maven.tools.targets</groupId> <artifactId>java-specs</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>- third-party
此相依關係包含協力廠商實作相依關係。此相依關係可適用於 Liberty 安裝架構 dev/api/third-party 和 dev/spi/third-party 目錄中的協力廠商程式庫。
<dependency> <groupId>net.wasdev.maven.tools.targets</groupId> <artifactId>third-party</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>
- 將 RELEASE 變數變更為
您的 WebSphere Application Server Liberty 版本。
例如,若為 WebSphere Application Server Liberty 8.5.5.9 版,可將 RELEASE 變更為 8.5.5.9。
提示: 如果您沒有編輯 RELEASE 值,依預設,工具會使用最新的可用版本。 - 使用這些 Snippet 來指定伺服器執行時期環境 API,以編譯 Java EE 和 OSGi 應用程式。
- 選擇 Maven 相依關係之下列其中一個 Snippet 的適用版本。
- 若為 WebSphere Application Server Liberty 8.5.5.4 版、8.5.5.5 版、8.5.5.6 版或 8.5.5.7 版,請完成下列步驟:
- 將 IBM Maven 儲存庫配置為 Maven 遠端儲存庫,以指出模擬執行時期環境類別路徑的相依關係。
如需配置 IBM Maven 儲存庫的相關資訊,請參閱設定 IBM Maven 儲存庫。
- 選擇下列其中一項相依關係的適用版本。
- was-liberty
此相依關係可適用於所有 WebSphere Application Server Liberty API、SPI,以及建議的 Java 規格相依關係。
<dependency> <groupId>com.ibm.tools.target</groupId> <artifactId>was-liberty</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>- was-liberty-impl
此相依關係包含 Open JPA、Wind 和 Jackson 等之類的協力廠商實作程式庫。
<dependency> <groupId>com.ibm.tools.target</groupId> <artifactId>was-liberty-impl</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>
- 將 RELEASE 變數變更為您
WebSphere Application Server Liberty 版本的對應 Maven 相依關係版本。
您可以使用下列圖表, 來判斷您 WebSphere Application Server Liberty 版本的對應 Maven 相依關係版本:
WebSphere Application Server Liberty 版本 Maven 相依關係版本 8.5.5.9 8.5.x.6 或 RELEASE 8.5.5.8 8.5.x.5 8.5.5.7 8.5.x.4 8.5.5.6 8.5.x.3 8.5.5.5 8.5.x.2 8.5.5.4 8.5.x.1 例如,若為 WebSphere Application Server Liberty 8.5.5.5 版,可以將 RELEASE 變更為 8.5.x.2。
提示: 如果您沒有編輯 RELEASE 值,依預設,工具會使用最新的可用版本。
- 將 IBM Maven 儲存庫配置為 Maven 遠端儲存庫,以指出模擬執行時期環境類別路徑的相依關係。
- 若為 WebSphere Application Server 傳統版,請參閱將伺服器 API 安裝到 Maven 儲存庫。