2.2. Spring Boot 2.x の Fuse Console へのアクセス

スタンドアロン Fuse Spring Boot 2.x ディストリビューションの Fuse Console にアクセスできます。

手順

  1. 以下の依存関係を Fuse アプリケーションの pom.xml ファイルに追加します。

    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-springboot</artifactId>
    </dependency>

    バージョンは Maven BOM によって提供されるため、指定する必要はありません。

  2. src/main/resources/application.properties ファイルを編集します。

    1. 以下のプロパティーを設定します。

      • management.endpoints.web.exposure.include=hawtio,jolokia
      • hawtio.authenticationEnabled=false
      • management.endpoint.hawtio.enabled=true
      • management.endpoint.jolokia.enabled=true
    2. 任意で、management.endpoints.web.base-path プロパティーを設定します。

      Spring Boot 2.x のデフォルトでは、Fuse Console の URL に管理エンドポイントのコンテキストパス (/actuator) が含まれます。以下に例を示します。

      http://localhost:10001/actuator/hawtio/index.html

      このデフォルト URL を変更し、たとえば Spring Boot 1.x のデフォルトの URL と同じ形式 (http://localhost:10001/hawtio) を指定するには、management.endpoints.web.base-path プロパティーを以下のように設定します。

      management.endpoints.web.base-path=/

      application.properties 設定は以下の例のようになるはずです。

      # ports
      
      server.port=8080
      
      management.server.port=10001
      
      # enable management endpoints for healthchecks and hawtio
      
      management.endpoints.enabled-by-default = false
      
      management.endpoint.hawtio.enabled = true
      
      management.endpoint.jolokia.enabled = true
      
      management.endpoints.health.enabled = true
      
      management.health.defaults.enabled=false
      
      camel.health.enabled=false
      
      camel.health.indicator.enabled=true
      
      management.endpoints.web.exposure.include=hawtio,jolokia
      
      hawtio.authenticationEnabled=false
      
      # change the URL so that it does not include the actuator folder
      
      management.endpoints.web.base-path=/
      注記

      デフォルトでは、Spring Boot の Fuse Console の認証は無効になっています。任意で、Fuse Console ディストリビューションに固有するコードを作成すると、認証を有効にすることができます。例は次のとおりです。

      https://github.com/hawtio/hawtio/tree/master/examples/springboot-authentication

  3. Fuse アプリケーションを実行します。

    mvn spring-boot:run
  4. Fuse Console の URL のポート番号を特定するには、src/main/resources/application.properties ファイルで management.server.port の設定値を見つけます。以下に例を示します。

    management.server.port   = 10001
  5. ブラウザーで Fuse Console を開くには、以下の URL 構文を使用します。nnnnnmanagement.server.port プロパティーの値に置き換えます。

    http://localhost:nnnnn/actuator/hawtio

    たとえば、management.server.port プロパティーの値が 10001 で、management.endpoints.web.base-path プロパティーが設定されていない場合、URL は以下になります。

    http://localhost:10001/actuator/hawtio/index.html