配置依赖关系 POM 文件,这些文件模拟特定 WebSphere 运行时环境的类路径
您可以使用目标项目对象模型 (POM) 文件作为 Maven 依赖关系。这些依赖关系模拟 WebSphere 运行时环境的类路径以编译 Java EE 和 OSGi 应用程序。
关于此任务
必须根据您正使用的 WebSphere Application Server Liberty 或传统版的版本,以不同方式配置目标 POM 文件。
过程
- 对于 WebSphere Application Server Liberty V8.5.5.8 和更高版本,完成以下步骤:
- 选择 Maven 依赖关系的以下其中一个片段的适用版本。
以下片段属于 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 V8.5.5.9,可将 RELEASE 更改为 8.5.5.9。
提示: 如果未编辑 RELEASE 值,那么缺省情况下,工具会使用最新可用版本。 - 使用这些片段指定服务器运行时环境 API 以编译 Java EE 和 OSGi 应用程序。
- 选择 Maven 依赖关系的以下其中一个片段的适用版本。
- 对于 WebSphere Application Server Liberty V8.5.5.4、V8.5.5.5、V8.5.5.6 或 V8.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 依赖关系版本。
您可以使用以下图表,确定哪个 Maven 依赖关系版本与 WebSphere Application Server Liberty 的版本对应:
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 V8.5.5.5,可以将 RELEASE 更改为 8.5.x.2。
提示: 如果未编辑 RELEASE 值,那么缺省情况下,工具会使用最新可用版本。
- 将 IBM Maven 存储库配置为 Maven 远程存储库,以指示模拟运行时环境的类路径的依赖关系。
- 对于 WebSphere Application Server 传统版,请参阅将服务器 API 安装到 Maven 存储库中。