情報

/actuator/info は、どのビルドが動いているかを伝えます。その名前とバージョン、ビルド元の git のコミット、追加した任意の詳細、そして任意でオペレーティングシステムと Dart のバージョンです。各部分は情報コントリビューターから来ます。

使う理由

本番で何か問題が起きたとき、最初の問いはどのバージョンが動いているかです。info エンドポイントは、独自のコントローラーなしに、あらゆる Spring のツールが読むのと同じ JSON でそれに答えます。

例

# lib/resources/application.yml
management:
  endpoints:
    web:
      exposure:
        include: health,info
  info:
    env:
      enabled: true
    dart:
      enabled: true
    git:
      mode: simple
info:
  app:
    team: neon-books
    support: [email protected]
$ curl localhost:8080/actuator/info
{"app":{"team":"neon-books","support":"[email protected]"},
 "git":{"branch":"main","commit":{"id":"4faa522","time":"2026-11-04T18:02:11Z"}},
 "build":{"artifact":"shop","name":"shop","version":"1.4.0"},
 "dart":{"version":"3.13.5","channel":"stable","runtime":{"name":"Dart VM","version":"3.13.5 (stable) ..."}}}

info はデフォルトでは公開されません。management.endpoints.web.exposure.include に追加してください。

コントリビューター

コントリビューター 表示するもの デフォルト 切り替えるもの
build spring.info.build.location (resources:build-info.properties) の build.* キー: build.name、build.version、build.time... ファイルがあれば有効 management.info.build.enabled
git spring.info.git.location (resources:git.properties) の git.* キー。simple モード (ブランチ、短いコミット ID、時刻) または full (すべてのキー) ファイルがあれば有効 management.info.git.enabled、management.info.git.mode
env プレフィックスを除いた info.* プロパティ 無効 management.info.env.enabled
os オペレーティングシステムの name、version、arch 無効 management.info.os.enabled
dart Dart の version、channel、runtime (Spring Boot の java) 無効 management.info.dart.enabled

build と git は、自分のキーが設定されていなければ management.info.defaults.enabled に従います。

ビルドと git のファイル

キー デフォルト 意味
spring.info.build.location resources:build-info.properties ビルド情報の場所 (resources: または file:)
spring.info.build.encoding UTF-8 そのエンコーディング: UTF-8 または ISO-8859-1
spring.info.git.location resources:git.properties git の情報の場所
spring.info.git.encoding UTF-8 そのエンコーディング

Actuator に依存するアプリケーション (pubspec.yaml に publish_to: none) については、ジェネレーターが pubspec.yaml から build.artifact、build.name、build.version を持つ build-info.properties を埋め込みます。ビルド時刻は書かないため、生成コードはビルドごとに同じままです。さらに追加するには (時刻、CI のビルド番号)、独自の lib/resources/build-info.properties を置いてください。それが生成されたものを置き換えます。

git.properties は生成されません。CI で build_runner の前に書いてください。たとえば:

cat > lib/resources/git.properties <<EOF
git.branch=$(git rev-parse --abbrev-ref HEAD)
git.commit.id=$(git rev-parse HEAD)
git.commit.id.abbrev=$(git rev-parse --short HEAD)
git.commit.time=$(git log -1 --format=%cI)
EOF

時刻は ISO 8601 の時点、またはエポックからのミリ秒として読まれ、Spring Boot と同じ形式 (2026-11-05T09:12:44Z) で書かれます。

BuildProperties と GitProperties の Bean

ファイルが存在する場合、buildProperties と gitProperties の Bean は、「バージョン情報」のページやログの行のために、同じ値をアプリケーションに提供します。

@Component()
@Log()
class VersionLog implements ApplicationRunner {
  VersionLog(this.build);

  final BuildProperties build;

  @override
  void run(ApplicationArguments args) => log.info('Running ${build.name} ${build.version}');
}

独自のコントリビューター

InfoContributor の Bean は、その詳細を追加します。

@Component()
class CatalogInfoContributor implements InfoContributor {
  CatalogInfoContributor(this.catalog);

  final Catalog catalog;

  @override
  void contribute(InfoBuilder builder) =>
      builder.withDetail('catalog', {'books': catalog.size});
}

ライブラリは @ConditionalOnEnabledInfoContributor('catalog') (management.info.catalog.enabled) で自分のコントリビューターを切り替えます。

Spring (Java) との対応

コントリビューターもプロパティも同じです。ただし: java は dart です。os の値は Dart のもの (Platform.operatingSystem) です。process と ssl はありません。ファイルは resources: から読まれ (Spring Boot: classpath:META-INF/build-info.properties と classpath:git.properties)、build-info.properties は Maven や Gradle のプラグインではなくジェネレーターが書きます。

関連項目