Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing current Spring (Boot) properties

I run a Spring Boot application as a .jar file which partly takes its properties from application.yml residing inside the jar while the other part of properties is being provided from another application.yml residing outside the jar. Some of the properties from the outside overwrite the properties from the inside. In order to test whether the properties were overwritten properly I would like to see the currently active ones. Is that achieveable at all out of the box? Or is the only solution to extend my application by property output logic?

like image 733
Ewgenij Sokolovski Avatar asked Mar 28 '17 13:03

Ewgenij Sokolovski


1 Answers

At least as of spring boot 2.0 actuator/env will return the list of all properties per propertySources in order of their precedence, ie. if a property is redefined in >1 sources then the 1st occurrence reading from the top is the one that is active.

For a single property actuator/env/<property-name> will return the effective value and in which source it's defined

{
    "property": {
        "source": "applicationConfig: [file:../application-tom.properties]",
        "value": "DEBUG"
    },
...
}

Note: I dont know if this would reflect any changes that might happen when programmatically modifying the spring context. But that is smth. one should not do anyhow.

like image 149
elonderin Avatar answered Sep 19 '22 21:09

elonderin