My Spring class implements EmbeddedValueResolverAware
You then need to implement the setEmbeddedValueResolver method, so you create a field in your class:
private StringValueResolver stringValueResolver; public void setEmbeddedValueResolver(StringValueResolver stringValueResolver) { this.stringValueResolver = stringValueResolver; }
Now let's say have a props file:
something.1.foo=something2
something.2.foo=something1
In my Spring class above I can look it up dynamically...
int dynamicVal = getSomeDyanmicVal(); String foo = stringValueResolver.resolveStringValue("${something."+dynamicVal+".foo}");
No comments :
Post a Comment