1.2. 将应用程序项目配置为使用 Dekorate

将 Dekorate BOM 和 OpenShift Annotations Starter 添加到应用程序项目的 pom.xml 文件中。在源文件中包含基本注解,并使用 Maven 打包应用程序,以生成应用程序清单。

先决条件

  • 基于 Maven 的 Java 应用程序项目配置为使用 Spring Boot。
  • Java JDK 8 或 JDK 11 已安装。
  • 已安装 Maven。

流程

  1. 将 Dekorate OpenShift Spring Starter 添加到应用程序的 pom.xml 文件中,以启用 Dekorates,以接收应用程序源代码和资源文件:

    <project>
      ...
      <dependencies>
         ...
        <dependency>
          <!-- The OpenShift Spring Starter automatically imports the "io.dekorate:openshift-annotations" dependency. -->
          <groupId>io.dekorate</groupId>
          <artifactId>openshift-spring-starter</artifactId>
          <version>${dekorate.version}</version>
        </dependency>
        ...
      </dependencies>
    ...
    <project>
  2. @SpringBootApplication 注解添加到应用程序项目的主类文件中:

    package org.acme;
    
    @SpringBootApplication
    public class Application {
    }
  3. 打包应用程序,以处理带有 Dekorate 的应用程序代码和资源文件

    mvn clean package
  4. 导航到包含生成的 OpenShift 清单的 target/classes/META-INF/dekorate 目录。