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

配置更新后的问题 #1641

Closed
ghost opened this issue Nov 5, 2018 · 8 comments
Closed

配置更新后的问题 #1641

ghost opened this issue Nov 5, 2018 · 8 comments

Comments

@ghost
Copy link

ghost commented Nov 5, 2018

研究源码的时候,发现配置更新后,会自动更新springvalue对象

求教这些SpringValue是在哪里被使用的?

为什么@value对应的值也会被自动更新?

@ghost
Copy link
Author

ghost commented Nov 5, 2018

@nobodyiam @marsqing

@tianmingxing
Copy link

从v0.10.0开始的版本支持placeholder在运行时自动更新,具体参见PR #972

如果需要关闭placeholder在运行时自动更新功能,可以通过以下两种方式关闭:

通过设置System Property apollo.autoUpdateInjectedSpringProperties,如启动时传入-Dapollo.autoUpdateInjectedSpringProperties=false

通过设置META-INF/app.properties中的apollo.autoUpdateInjectedSpringProperties属性,如

app.id=SampleApp
apollo.autoUpdateInjectedSpringProperties=false

@ghost
Copy link
Author

ghost commented Nov 5, 2018

从v0.10.0开始的版本支持placeholder在运行时自动更新,具体参见PR #972

如果需要关闭placeholder在运行时自动更新功能,可以通过以下两种方式关闭:

通过设置System Property apollo.autoUpdateInjectedSpringProperties,如启动时传入-Dapollo.autoUpdateInjectedSpringProperties=false

通过设置META-INF/app.properties中的apollo.autoUpdateInjectedSpringProperties属性,如

app.id=SampleApp
apollo.autoUpdateInjectedSpringProperties=false

你好,谢谢你的回复

我看了下这个PR,发现在ApolloSpringApplicationRunListener里面会更新environment

但是现在的master没有ApolloSpringApplicationRunListener这个类了
我也找不到哪里会在配置更新后更新environment

@nobodyiam
Copy link
Member

@reenWYJ

看一下AutoUpdateConfigChangeListener

@ghost
Copy link
Author

ghost commented Nov 5, 2018

@reenWYJ

看一下AutoUpdateConfigChangeListener

这个类我看过的

但是发现它是直接从
Object value = placeholderHelper
.resolvePropertyValue(beanFactory, springValue.getBeanName(), springValue.getPlaceholder());
这行代码获取到了最新的配置

问题就是placeholderHelper.resolvePropertyValue()这个方法是从environment里面取得值

所以environment在什么时候什么地方更新的?

谢谢指教

@ghost
Copy link
Author

ghost commented Nov 5, 2018

@nobodyiam

@nobodyiam
Copy link
Member

看一下environment里面的property source就明白了,不存在更新environment这一说。

@ghost
Copy link
Author

ghost commented Nov 6, 2018

看一下environment里面的property source就明白了,不存在更新environment这一说。

谢谢,看懂了这一块的东西

原来更新config对象就行了,不用再更新environment了

@ghost ghost closed this as completed Nov 14, 2018
This issue was closed.
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