Replies: 1 comment
-
ConfigChangeEvent 只是事件,对实际的配置没有影响的,如果要修改配置的话,可以参考 #1459 (comment) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
// 需求:在监听到修改的属性值是P[ 开头的时候,想把该值修改为OPT开头的新值
// 代码如下,但是实际并未修改成功,想知道如何实现
@ApolloConfigChangeListener
private void onChange(ConfigChangeEvent changeEvent) {
for (String key : changeEvent.changedKeys()) {
ConfigChange change = changeEvent.getChange(key);
if (change.getNewValue().startsWith("P[") &&
change.getNewValue().endsWith("]")) {
// 满足条件的场合,修改为新的值
change.setNewValue("OPT" + change.getNewValue());
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions