So far, I have seen methods to update a Spring boot application, by changing the property file itself, then reloading the file, or by using @RefreshScope
annotation, or by Spring Cloud Config.
I was not able to find anything straight forward (something like getEnvironment().updateProperty(key, value)
).
Is there such a way to do that?
For example, I need to change the logging type of my application, to show the SQL;
My application.properties
file contains this line: spring.jpa.show-sql=false
.
But what if I want to set this to true
while the application is running, through a REST call?
Can you suggest a simpler way to do this? And/Or show examples of how you would do it yourself, for this specific property?
EDIT: The changes do not need to be reflected in the application.properties
file. So when the application is restarted, it would use the properties that were initially set in the application.properties
file.