第12章 Karaf イメージのアプリケーションの開発

このチュートリアルでは、Karaf イメージのアプリケーションを作成およびデプロイする方法を説明します。

12.1. Maven archetype を使用した Karaf プロジェクトの作成

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

手順

  1. システムの適切なディレクトリーに移動します。
  2. Maven コマンドを起動して、Karaf プロジェクトを作成します。

    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-sb2-780040-redhat-00002/archetypes-catalog-2.2.0.fuse-sb2-780040-redhat-00002-archetype-catalog.xml \
      -DarchetypeGroupId=org.jboss.fuse.fis.archetypes \
      -DarchetypeArtifactId=karaf-camel-log-archetype \
      -DarchetypeVersion=2.2.0.fuse-sb2-780040-redhat-00002
  3. archetype プラグインは対話モードに切り替わり、残りのフィールドを追加するよう要求します。

    Define value for property 'groupId': : org.example.fis
    Define value for property 'artifactId': : fuse78-karaf-camel-log
    Define value for property 'version':  1.0-SNAPSHOT: :
    Define value for property 'package':  org.example.fis: :
    Confirm properties configuration:
    groupId: org.example.fis
    artifactId: fuse78-karaf-camel-log
    version: 1.0-SNAPSHOT
    package: org.example.fis
     Y: : Y

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

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

    cd fuse78-karaf-camel-log
    mvn fabric8:deploy -Popenshift
注記

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