How to update configuration of SpringBoot application at runtime without reloading whole ApplicationContext

前端 未结 1 585
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 02:15

I am trying to figure out how can I dynamically update/reload externalized configuration in a Spring Boot application without restarting the whole application.

Most

相关标签:
1条回答
  • 2021-01-03 02:57

    It sounds like you're looking for @RefreshScope which is provided by Spring Cloud. From the Spring Cloud documentation:

    A Spring @Bean that is marked as @RefreshScope will get special treatment when there is a configuration change. This addresses the problem of stateful beans that only get their configuration injected when they are initialized. For instance if a DataSource has open connections when the database URL is changed via the Environment, we probably want the holders of those connections to be able to complete what they are doing. Then the next time someone borrows a connection from the pool he gets one with the new URL.

    0 讨论(0)
提交回复
热议问题