4.3. スタンドアロン Red Hat Enterprise Linux への Spring Boot アプリケーションのデプロイ

Spring Boot アプリケーションをスタンドアロンの Red Hat Enterprise Linux にデプロイするには、アプリケーションで pom.xml ファイルを設定し、Maven を使用してパッケージ化し、java-jar コマンドを使用してデプロイします。

前提条件

  • RHEL 7 または RHEL 8 がインストールされている。

4.3.1. スタンドアロン Red Hat Enterprise Linux デプロイメント用の Spring Boot アプリケーションの準備

Spring Boot アプリケーションをスタンドアロンの Red Hat Enterprise Linux にデプロイするには、最初に Maven を使用してアプリケーションをパッケージ化する必要があります。

前提条件

  • Maven がインストールされている。

手順

  1. 以下の内容をアプリケーションの root ディレクトリーの pom.xml ファイルに追加します。

      ...
      <!-- Specify target artifact type for the repackage goal. -->
      <packaging>jar</packaging>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring-boot.version}</version>
            <executions>
              <execution>
                  <goals>
                   <goal>repackage</goal>
                 </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
  2. Maven を使用してアプリケーションをパッケージ化します。

    $ mvn clean package

    作成される JAR ファイルは target ディレクトリーに置かれます。