Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用EnvironmentChangeEvent 但是配置没有更新 #5234

Open
Shy-Chen opened this issue Sep 20, 2024 · 1 comment
Open

使用EnvironmentChangeEvent 但是配置没有更新 #5234

Shy-Chen opened this issue Sep 20, 2024 · 1 comment

Comments

@Shy-Chen
Copy link

参考官方的demo 使用如下这种方式来刷新@ConfigurationProperties配置文件 但是没有生效
this.applicationContext.publishEvent(new EnvironmentChangeEvent(changedKeys));
请教下这个是什么问题?

@nobodyiam
Copy link
Member

需要注意的是,@ConfigurationProperties如果需要在Apollo配置变化时自动更新注入的值,需要配合使用EnvironmentChangeEventRefreshScope。相关代码实现,可以参考apollo-use-cases项目中的ZuulPropertiesRefresher.java和apollo-demo项目中的SampleRedisConfig.java以及SpringBootApolloRefreshConfig.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants