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

@ConfigurationProperties 注解里的map增加新的k,v无效 #5341

Open
skillblue001 opened this issue Feb 19, 2025 · 2 comments
Open

@ConfigurationProperties 注解里的map增加新的k,v无效 #5341

skillblue001 opened this issue Feb 19, 2025 · 2 comments

Comments

@skillblue001
Copy link

描述bug

基于RefreshScope 刷新,@ConfigurationProperties配置的类,通过@EnableConfigurationProperties,创建的无效,按demo(https://github.com/apolloconfig/apollo-demo-java/blob/main/spring-boot-demo/src/main/java/com/apolloconfig/apollo/demo/springboot/refresh/SpringBootApolloRefreshConfig.java)中使用,删除、修改类中配置的map已有的key有效,但是添加新的配置无效(在调用RefreshScope.refresh方法之前通过ConfigurableEnvironment确认配置的已经添加到上下文中了),通过/actuator/refresh刷新正常有效,

复现

通过如下步骤可以复现:

  1. 服务启动后,在配置中心添加对应此map对应的配置
  2. 通过日志或者接口获取,无效
  3. 调用 curl -X POST http://localhost:27117/actuator/refresh 刷新
  4. 通过接口获取,此类中的map中已经添加刚刚配置的k,v

额外的细节和日志

  • 版本: <apollo.version>2.3.0</apollo.version>, <boot.version>2.3.12.RELEASE</boot.version>, <spring-cloud.version>Hoxton.SR12</spring-cloud.version>

  • 错误日志

  • 配置:

  • 平台和操作系统

Copy link

dosubot bot commented Feb 19, 2025

Hey there, @skillblue001! 👋 I'm here to help with any bugs, questions, or contributions you have in mind. I'm a bot designed to assist you while waiting for a human maintainer. Let's tackle this issue together!

I found a similar closed issue regarding the problem where Spring Boot listens to the configuration update action, but the new value is not updated [1]. However, no solution was found in the comments of that issue.

Regarding your issue with @ConfigurationProperties and @RefreshScope, it seems that the refresh mechanism is functioning but not capturing new properties added post-startup. This behavior might be due to how @ConfigurationProperties handles map structures. Unfortunately, I couldn't find specific documentation or known issues related to this in the Apollo repository.

One potential workaround is to ensure that the /actuator/refresh endpoint is used to trigger a refresh, as you mentioned it works correctly in your case. This endpoint forces a refresh of the application context, which might be necessary for new key-value pairs to be recognized.

If you haven't already, you might want to explore the possibility of using a custom refresh mechanism or checking if there are any updates or patches in newer versions of Apollo or related libraries that address this issue.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@skillblue001
Copy link
Author

网络问题,提交多了

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

1 participant