Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda