Display deployed version on your maven powered Spring application

Sometimes it is useful to have an endpoint that will return your application’s maven build properties.

To set that up, there are only a few steps that need to be followed.

First, define the resource directory.  By default, Maven will look in src/main/resources. Regardless, it is a good idea to add the resources and set filtering to true.

You will need to include Maven resources plugin. Using @ helps with avoiding collisions with Spring placeholders.

Define the properties you are interested in having access to in your application.properties file.

You can now have an endpoint that will return these values.

References

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html

https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

https://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html

Leave a Reply

Your email address will not be published. Required fields are marked *