Help us understand the problem. What is going on with this article?

SpringBootでリリースモジュールのGit情報を表示する

More than 3 years have passed since last update.

概要

  • SpingBootでリリースしたWEBアプリのバージョンを表示させる
    • Gitの情報を表示するEndpointを作成する
  • EndpointはSpringBootのActuatorを使い、http://host名/infoにアクセスすることでjsonで取得できるようにする
  • Gradleで実施

手順

build.gradleを設定

  • build.gradleにgradle-git-propertiesを設定
  • build.gradleにSpring Actuatorを設定
build.gradle(抜粋)
buildscript {
    repositories {
      mavenCentral()
      maven {
        url "https://plugins.gradle.org/m2/"
      }
    }
    dependencies {
      classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.16"
    }

}

apply plugin: 'com.gorylenko.gradle-git-properties'

...

dependencies {

...

    compile "org.springframework.boot:spring-boot-starter-actuator"

...

}

gradleでビルド

gradle build
  • ビルド時に自動的にgit-propertiesを作成するtaskが実行される

確認

  • ビルドでできたjarを実行しブラウザからアクセス
  • http://localhost:8080/infoのように/infoから取得できる

  • 実行結果イメージ
    image

AkihiroTakamura
仕事でやったことを問題ない範囲で気ままに上げていきます web系多し
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした