简体   繁体   中英

spring-cloud how to use Endpoints

management endpoints:

For a Spring Boot Actuator application there are some additional management endpoints:

    POST to /env to update the Environment and rebind @ConfigurationProperties and log levels

http://localhost:8080/env/testprop it works and returns:

{
"testprop": "test value"
}

but when I do POST: http://localhost:8080/env/testprop Request method 'POST' not supported

I want to update testprop , how to do it with API?

I found the following in the docs

For a Spring Boot Actuator application there are some additional management endpoints:

  • POST to /env to update the Environment and rebind @ConfigurationProperties and log levels

  • /refresh for re-loading the boot strap context and refreshing the @RefreshScope beans

  • /restart for closing the ApplicationContext and restarting it (disabled by default)

  • /pause and /resume for calling the Lifecycle methods (stop() and start() on the ApplicationContext)

Looks like you have to post agains /env instead of /end/$yourProperty

Ok, it works: must POST with empty body http://localhost:8080/env/?test=dasda and response is:

{
    "test": "dasda"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM