How to get the spring boot version in the / info drive endpoint

It is possible to enable the Spring Boot version in banner.txt by adding ${spring-boot.version}

How can I do the same for the drive endpoint / info. I tried to add both

info.app.spring-boot.version=${spring-boot.version}

and

info.app.spring-boot.version=@spring-boot.version@

to my app properties but no luck. The / info endpoint will print "$ {spring-boot.version}" (or "@spring-boot.version @"), does not resolve the placeholder variable

My next idea was to create a maven property for the Spring Boot version and reference it in the parent section like so:

<properties>
    <spring.boot.version>1.5.3.RELEASE</spring.boot.version>
</properties

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>${spring.boot.version}</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

      

But it didn't work because maven allows placeholder variables AFTER processing the section

UPDATE: The following works, but it's not perfect

@Component
public class MyInfoContributor implements InfoContributor {
    @Override
    public void contribute(Info.Builder builder) {

        builder.withDetail("spring-boot.version", SpringBootVersion.getVersion());
    }
}

      

+3


source to share


1 answer


This should work:

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <additionalProperties>
      <spring-boot-version>${spring.boot.version}</spring-boot-version>
    </additionalProperties>
  </configuration>
</plugin>

      



You don't need app.info properties.

0


source







All Articles