第5章 Spring Boot イメージのアプリケーションの開発

本章では、Spring Boot イメージのアプリケーションを開発する方法を説明します。

5.1. Maven archetype を使用した Spring Boot プロジェクトの作成

Maven archetype を使用して Spring Boot プロジェクトを作成するには、以下の手順にしたがいます。

手順

  1. システムの適切なディレクトリーに移動します。
  2. シェルプロンプトで以下の mvn コマンドを入力し、Spring Boot プロジェクトを作成します。

    mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate \
      -DarchetypeCatalog=https://maven.repository.redhat.com/ga/io/fabric8/archetypes/archetypes-catalog/2.2.0.fuse-760024-redhat-00001/archetypes-catalog-2.2.0.fuse-760024-redhat-00001-archetype-catalog.xml \
      -DarchetypeGroupId=org.jboss.fuse.fis.archetypes \
      -DarchetypeArtifactId=spring-boot-camel-xml-archetype \
      -DarchetypeVersion=2.2.0.fuse-760024-redhat-00001

    archetype プラグインが対話モードに切り替わり、残りのフィールドの入力を要求されます。

    Define value for property 'groupId': : org.example.fis
    Define value for property 'artifactId': : fuse76-spring-boot
    Define value for property 'version':  1.0-SNAPSHOT: :
    Define value for property 'package':  org.example.fis: :
    Confirm properties configuration:
    groupId: org.example.fis
    artifactId: fuse76-spring-boot
    version: 1.0-SNAPSHOT
    package: org.example.fis
     Y: : Y

    プロンプトが表示されたら、org.example.fisgroupId の値として入力し、fuse76-spring-bootartifactId の値として入力します。残りのフィールドではデフォルト値を使用します。

  3. 上記のコマンドが BUILD SUCCESS 状態で終了した場合、fuse76-spring-boot サブディレクトリー内に新しい Fuse on OpenShift プロジェクトが作成されているはずです。
  4. これで、fuse76-spring-boot プロジェクトをビルドおよびデプロイできるようになりました。OpenShift にログインしている状態で、fuse76-spring-boot プロジェクトのディレクトリーに移動し、以下のようにプロジェクトをビルドおよびデプロイします。

    cd fuse76-spring-boot
    mvn fabric8:deploy -Popenshift
注記

使用できる Spring Boot archetype の完全リストは、Spring Boot archetype カタログ を参照してください。