I want to used the spring-boot-starter-actuator to expose git info on server. And i already generated the file 'git.properties' into target/classes/, But the filed git is empty when access the /actuator/info.

The spring-boot version: 2.5.8 The jdk version: 1.8.0_321

The config in application.yml:

management:
  endpoints:
    web:
      exposure:
        include: 'health,metrics,info'
  info:
    git:
      enabled: true
      mode: full

The maven pom file:

<build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>*.properties</exclude>
                    <exclude>*.xml</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>4.9.10</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <prefix>git</prefix>
                    <verbose>true</verbose>
                    <dateFormat>yyyy-MM-dd':'HH:mm:ssZ</dateFormat>
                    <!-- generated git.properties file-->
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
<!--                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>-->
                    <format>json</format>
                    <gitDescribe>
                        <skip>false</skip>
                        <always>false</always>
                        <abbrev>7</abbrev>
                        <dirty>-dirty</dirty>
                    </gitDescribe>
                </configuration>
            </plugin>
        </plugins>
    </build>

When i access the /actuator/info and get

{"git":{},"grpc.server":{"port":9119,"services":{"developer.FlinkDeveloper":["CancelFlinkJob","GetFlinkJobsByUrl","GetFlinkJobStatus","ParseFlinkJobToGraph","SubmitFlinkJob","ValidateFlinkJob","ValidateFlinkJobContext"],"grpc.health.v1.Health":["Check","Watch"],"grpc.reflection.v1alpha.ServerReflection":["ServerReflectionInfo"]}}}

Run the app command line:

java -jar xxx.jar -Dspring.config.location=xxxx/target/classes/application.yml  --logging.config=xxxx/src/main/resources/log4j2.xml

How can i make the git.properties work when start the server. Thanks.

Comment From: wilkinsona

You have configured the plugin to generate json:

<format>json</format>

You need to use the default properties format. This can be achieved by removing the configuration of the format.

Comment From: yu31

You have configured the plugin to generate json:

<format>json</format>

You need to use the default properties format. This can be achieved by removing the configuration of the format.

Thanks