Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
spring-cloud-starter-config POST /env not working

I have a little spring boot web application (executable jar) which has some custom properties inside the application.properties file. My goal is to be able to dynamically alter these properties at runtime without having to run a build/deploy or restarting the java process. The spring-cloud-starter-config project seems to be well suited for this (even though I am not using a config server) but I ran into the following problem:

In my pom.xml I include dependencies to spring-boot-starter-actuator and spring-cloud-starter-config. The application.properties configures below properties

management.port=8081
management.context-path=/management
management.security.enabled=false
foo=bar

I can read the variables using

curl http://localhost:8081/management/env/foo
{"foo":"bar"}

Below update seems to succeed as well

curl -X POST -d foo=foo http://localhost:8081/management/env
{"foo":"foo"}

When I query the whole env I see the changed value in the manager section and the original value inside applicationConfig

curl http://localhost:8081/management/env
{
  ...
  "manager": {
    "foo": "foo"
  },
  ...
  "configServerClient": {
    "spring.cloud.config.enabled": "false"
  },
  ...
  "applicationConfig: [classpath:/application.properties]": {
  ...
  "foo": "bar",
  ...
  }
}  

Now when I query the variable again I still get the old value

curl http://localhost:8081/management/env/foo
{"foo":"bar"}

This is contrary to what I read on some web blogs. In my understanding the changed value should show up. What am I doing wrong? Is there a better way to dynamically change values in the application.properties without restarting the server?

Your help is much appreciated.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

You need to run refresh after posting changes to env

curl -X POST http://localhost:8081/management/refresh
about 4 years ago · Santiago Trujillo Report

0

for me it only works with

curl -H "Content-Type: application/json" -X POST -d '{"name":"foo", "value":"bar"}' http://localhost:8081/management/env/

otherwise I get

"Missing parameters: value,name"
about 4 years ago · Santiago Trujillo Report

0

If you are using a spring boot version greater than 2.2.4, then you have to manually enable the POST API call using the below the property.

management.endpoint.env.post.enabled=true

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!