我能否仅在云配置服务器中使用 @RefreshScope
(连同属性上的 @Value
),或者我是否也可以在没有配置服务器的情况下使用?我正在尝试在没有配置服务器的情况下使用它。我试图通过更改 .property 文件中的值并尝试再次请求来获取 @Value
属性,我会得到更新的值吗?那可能吗?
最佳答案
不,您应该将它与配置服务器一起使用,否则您将无法即时读取更新属性。关注this article看看this如果您在动态加载更新的属性时遇到任何问题。
In theory, you could refresh the application context, but I wouldn't recommend this. Spring Cloud has provided an annotation to mark a bean as refreshable. By adding spring actuator, we can refresh those beans on the fly.
关于java - Spring 配置@RefreshScope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53559009/