![](/img/trans.png)
[英]@refreshScope Spring cloud config doesn't refresh application.properties value
[英]spring boot, Not able to change the properties value at runtime using spring cloud config , @RefreshScope doesn't work
我正在使用 spring 雲配置在運行時更改屬性值,而無需重新啟動應用程序。
我有一個具有不同配置文件的存儲庫,並且基於配置文件,我有多個應用程序用完一個存儲庫。
我有一個帶有@Profile 注釋之一的服務 class,
@Service
@Slf4j
@Profile("change-feed")
@RefreshScope
public class ProcessorFeedService extends ProcessorService {
private final boolean toggle;
private final FeedPublisher publisher;
public ProcessorFeedService(FeedPublisher publisher,
@Value("${feed.toggle}") boolean toggle) {
this.publisher = publisher;
this.toggle = toggle;
}
public void handler(List<JsonNode> docs) {
for (JsonNode document : docs) {
try {
if (toggle) {
// do something
publisher.publish();
} else {
// do something else
inventoryChangePublisher.publish(document);
}
} catch (Exception ex) {
log.error("Exception occurred while processing {}", document.toString(), ex);
}
}
}
}
我有一個“ application-change-feed ”屬性文件和另一個應用程序測試文件,其中( application-test )在雲配置存儲庫中有這個feed.toggle屬性值。
application.properties 文件具有這些屬性以啟用刷新端點和所有
management.endpoints.web.exposure.include=info,health,env,refresh,bindings
management.endpoint.health.show-details=always
management.health.binders.enabled=true
spring.profiles.active=test
spring.profiles.include=change-feed
更改雲配置文件中的屬性值后,點擊此刷新端點https://{url}/actuator/refresh
它會返回更改后的屬性。 但它並不反映應用程序中的更新值。 應用程序只選擇舊的。
我究竟做錯了什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.