Auto Updating Spring Placeholder Values #972
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Auto Updating Spring Placeholder Values
1. Features
Spring placeholder values will now be auto updated when new configs are released in Apollo.
1.1
@Value
PlaceholdersFull support is provided for:
@Value
placeholders annotated on fields@Value
placeholders annotated on methods@Value
placeholders with Spring Expression LanguageFor example, the following 3 fields can all be auto updated when the corresponding config is changed:
Sample Configurations:
We also provide limited support for nested placeholders.
For example, with the following configurations and program:
batch
equals tonormalBatch
at first, so the initial nestedProperty equals to1000
batch
is changed tospecialBatch
, then the nestedProperty field will be changed to5000
batch
config and changenormalBatch
to5000
instead, then the nestedProperty won't be auto updated1.2 XML Placeholders
Full support is provided for placeholders for property field.
For example, the following 3 fields can all be auto updated when the corresponding config is changed:
Xml Config:
Sample Configurations:
We also provide limited support for nested placeholders, the same as
@Value
placeholders.2. Configuration
This auto update feature is turned on by default, you could turn off this feature by:
Specify
apollo.autoUpdateInjectedSpringProperties=false
in System PropertiesFor example, you may pass
-Dapollo.autoUpdateInjectedSpringProperties=false
when starting the Java programSpecify
apollo.autoUpdateInjectedSpringProperties=false
in META-INF/app.propertiesFor example,