3.3. Thorntail 应用程序 Maven 项目迁移


Red Hat build of Thorntail 正在接近其生命期。如果您有 Thorntail 应用,您可以将应用程序的 Maven 项目迁移到 JBoss EAP XP。Thorntail 应用程序以两种方式打包:

  • 与 Thorntail 运行时一起打包为 Uberjar,一个可执行 JAR,
  • 打包在标准 WAR 存档中,可在 Thorntail hollow JAR 中部署和运行,它是一个仅限运行时的可执行文件 JAR。

迁移到 JBoss EAP XP 时,T Thorntail 应用可以打包为可引导 JAR,并修剪 JBoss EAP XP 运行时,使其包含应用所依赖的 MicroProfile 平台和其他技术。

将应用程序迁移到 JBoss EAP XP 时,您必须删除任何 Thorntail 部分依赖项,并将任何所需 MicroProfile 和 Jakarta EE 8 规范的工件添加到 Maven 项目依赖项。

注意

您可以在运行时使用 JBoss CLI 工具或 JBoss EAP Web 控制台来更改服务器配置。但是,与打包过程中所做的配置更改不同,在运行时对配置所做的任何更改都不会保留,并在重启可引导 JAR 时丢失。

如果您的 Thorntail 应用依赖于 Jakarta Enterprise Beans、Jakarta Server Faces、Jakarta Connector API、SOAP Web 服务或 CORBA,您可以将应用的 Maven 项目迁移到 JBoss EAP XP。

Galleon 层用于配置打包在可引导 JAR 中的 JBoss EAP XP 运行时的功能。当您迁移使用 Jakarta EE 8 规范的 Thorntail 应用程序时,您必须将相关的 Galleon 层添加到可引导 JAR Maven 插件配置中。

使用 Galleon 层时,JBoss EAP XP 会生成一个服务器配置,并将其打包在可引导 JAR 中。如果没有使用 Galleon 层,则会在可引导 JAR 中打包与默认 standalone-microprofile.xml 相同的配置。

如果您要使用 <cloud> 配置元素为云 构建可引导 JAR,则与默认的 standalone-microprofile-ha.xml 类似的 OpenShift 配置将应用到您的可引导 JAR。

bootable JAR Maven 插件执行 JBoss CLI 脚本,同时打包可引导 JAR。

流程

  1. 删除任何 Thorntail BOM 导入。

    pom.xml 文件中删除 io.thorntail Thorntail BOM 导入的示例。

    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>io.thorntail</groupId>
          <artifactId>bom</artifactId>
          <version>${version.thorntail}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>
    Copy to Clipboard Toggle word wrap

  2. 使用 JBoss EAP XP BOMs 将支持的工件导入到 JBoss EAP XP 依赖项管理。

    使用 jboss-eap-jakartaee8-with-tools BOM 将支持的工件导入到项目的示例。

    <dependencyManagement>
            <dependencies>
                <!-- importing the jakartaee8-with-tools BOM adds specs and other useful artifacts as managed dependencies -->
                <dependency>
                    <groupId>org.jboss.bom</groupId>
                    <artifactId>jboss-eap-jakartaee8-with-tools</artifactId>
                    <version>${version.server.bom}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
                <!-- importing the microprofile BOM adds MicroProfile specs -->
                <dependency>
                    <groupId>org.jboss.bom</groupId>
                    <artifactId>jboss-eap-xp-microprofile</artifactId>
                    <version>${version.microprofile.bom}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    Copy to Clipboard Toggle word wrap

    注意

    只有在应用程序依赖于 MicroProfile 平台中没有包含的 Jakarta EE 8 规格时,才导入 jakartaee8-with-tools BOM。

  3. 将 Thorntail Maven 插件替换为 JBoss EAP XP bootable JAR Maven 插件。

    使用 JBoss EAP XP bootable JAR Maven 插件替换 Thorntail Maven 插件的示例。

    <plugin>
       <groupId>org.wildfly.plugins</groupId>
       <artifactId>wildfly-jar-maven-plugin</artifactId>
       <version>${bootable.jar.maven.plugin.version}</version>
       <configuration>
          <feature-pack-location>${org.jboss.eap:wildfly-galleon-pack:${jboss.xp.galleon.feature.pack.version}</feature-pack-location>
          <layers>
             <layer>microprofile-platform</layer>
          </layers>
       </configuration>
       <executions>
          <execution>
             <goals>
                <goal>package</goal>
             </goals>
          </execution>
       </executions>
    </plugin>
    Copy to Clipboard Toggle word wrap

    注意

    前面的示例为 Maven 插件版本指定以下属性:

    ${bootable.jar.maven.plugin.version}
    Copy to Clipboard Toggle word wrap

    您必须设置 Maven 插件版本,以代替项目中的此属性。例如:

    <properties>
        <bootable.jar.maven.plugin.version>6.1.2.Final-redhat-00001</bootable.jar.maven.plugin.version>
    </properties>
    Copy to Clipboard Toggle word wrap
    • 默认情况下,可引导 JAR 插件会构建 UberJAR,这意味着它将 JBoss EAP XP 运行时与部署的应用程序打包。要构建 hollow JAR,请在插件配置中添加 <hollow-jar>true</hollow-jar >。
  4. 在 Maven 项目中对 Thorntail 部分进行以下更改。

    1. 删除 Thorntail 部分依赖项。

      显示从 Maven 项目中删除 io.thorntail Thorntail 部分的示例。

      <dependencies>
        <dependency>
          <groupId>io.thorntail</groupId>
          <artifactId>jaxrs</artifactId>
        </dependency>
      </dependencies>
      Copy to Clipboard Toggle word wrap

    2. 配置 Maven 依赖项。

      使用 XML 片断向 Jakarta EE 8 JAX-RS 和 MicroProfile Config API 的工件中添加依赖项的示例。

      <dependencies>
          <!-- Import the MicroProfile Config API, we use provided scope as the API is included in the server -->
          <dependency>
            <groupId>org.eclipse.microprofile.config</groupId>
            <artifactId>microprofile-config-api</artifactId>
            <scope>provided</scope>
          </dependency>
          <!-- Import the Jakarta REST API, we use provided scope as the API is included in the server -->
          <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
            <scope>provided</scope>
          </dependency>
        </dependencies>
      Copy to Clipboard Toggle word wrap

    3. 删除 Thorntail YAML 文件、系统属性和环境属性。
    4. 配置 Galleon 层。

      为需要 JAX-RS 的应用在可引导 JAR Maven 插件中配置 Galleon 层的示例。

      <plugin>
        <groupId>org.wildfly.plugins</groupId>               <artifactId>wildfly-jar-maven-plugin</artifactId>                  <configuration>
         ...
            <layers>
              <layer>jaxrs-server</layer>
              <layer>microprofile-platform</layer>
            </layers>
        </configuration>
         ...
      </plugin>
      Copy to Clipboard Toggle word wrap

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部