Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda