How to List All Spring Boot Application Properties

Java Spring Boot

Spring Boot is simply fantastic. It’s so ergonomic, I could write microservices for days. But, sometimes, you run into a problem, and you need to find out what configuration your app is using. That can seem difficult. Fortunately, Spring Boot’s Actuator helps. Let’s see how.

Spring Boot Actuator is your friend

The Actuator is where all of Spring Boot’s admin and monitoring “stuff” lives.

The Actuator is a set of endpoints for monitoring and application admin.

In Spring Boot 2.x, all of its management features are wrapped up in a component called the Actuator. The Actuator is a set of HTTP endpoints, which you can use to monitor and interact with your app, do health-checks, and more.

In the Actuator, there are several different sub-endpoints, like env, health and metrics.

Each of these endpoints exposes some information about your application, which might be useful during development or even in production.

Fortunately, one of these endpoints exposes environment information.

Let’s see how to use it.

Using the Actuator to list all application properties

To see all properties in your Spring Boot application, enable the Actuator endpoint called env. This enables an HTTP endpoint which shows all the properties of your application’s environment.

The Spring Boot Actuator env endpoint
The Spring Boot Actuator env endpoint

You can do this by setting the property management.endpoints.web.exposure.include in your application.properties.

This property accepts a comma-separated list of the actuator endpoints that you want to expose (see here for them all).

The endpoint we’re interested in is env. You can enable it on its own, or combine it with other endpoints like health (which exposes application health info at /actuator/health).

Here’s what that looks like:

# Enable the env endpoint 
management.endpoints.web.exposure.include=env

# Or, enable the health and env endpoints
management.endpoints.web.exposure.include=env,health

Now restart your app, and you should be able to see all of your environment config at:

http://localhost:8080/actuator/env

So, if you want to see all of your application’s configuration properties (like those from application.properties, or from environment variables), then enable the env Actuator endpoint.

There’s also a really useful (and not very well-known!) trick that you can do with this env endpoint.

To inspect the value of a single property, add its name to the end of the URL

Once you’ve enabled the env Actuator endpoint, you can also look up the value of any single property, by appending it to the URL, like /actuator/env/favourite.cheese.

This endpoint will show you the value of a property, and exactly how its value was determined.

In my example here, I already set a property called favourite.cheese in my properties file. Then, I set an environment variable FAVOURITE_CHEESE, which overrides the value to roquefort (Roquefort is a very nice cheese):

Inspecting an individual Spring Boot property with the actuator
Inspecting an individual property

This trick lets you see the exact value that Spring Boot is using for a property, and why.

So, you can potentially figure out whether you’re talking to your dev database as expected, or….. whether you’re accidentally talking to production. (Oops.)

You might find this useful when you’re using environment variables to override Spring Boot properties in Kubernetes.

You probably don’t want to enable this feature in production

I’ll leave you with a final bit of advice: you probably don’t want to enable this in production.

What’s the risk, seriously?

If you enable your env endpoint in production, you could be exposing database passwords, message broker passwords, private keys and tons of other sensitive stuff.

So, unless you really need to expose this information in production, keep its use to development only!