LoginSignup
1
5

More than 5 years have passed since last update.

SpringBootActuatorを試してみる

Last updated at Posted at 2017-11-14

SpringActuatorとは

  • アプリの稼働状況などの情報を返すエンドポイントを勝手に作ってくれる

使い方

  • mavenの場合
pom.xml
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
  • gradleの場合
build.gradle
dependencies {
    compile("org.springframework.boot:spring-boot-starter-actuator")
}

動作確認

スクリーンショット 2017-11-15 7.53.51.png

いろいろなエンドポイント

公開設定の変更

  • 認証済みでないと公開しないかどうかは設定で変更できる
  • sensitiveをtrueにすると認証が必要になり、falseにすると必要なくなる
application.properties
endpoints.sensitive=false # 全エンドポイントまとめて指定する
endpoints.info.sensitive=false # 個別に指定する場合はこんな感じ
  • 各エンドポイントの有効無効の設定もできるので不要なものは閉じておくとよい
  • 設定のしかたはsensitiveと同じ感じ
application.properties
endpoints.enabled=false  # 全エンドポイントまとめて指定する
endpoints.info.enabled=false  # 個別に指定する場合はこんな感じ
  • SpringSecurityとの連動を解除することもできる
application.properties
management.security.enabled=false
1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5