I have a Spring-installed bean that loads properties using property-placeholder in the associated context.xml :
<context:property-placeholder location="file:config/example.prefs" />
I can access properties using Spring @Value annotations on initialization, for example:
@Value("${some.prefs.key}") String someProperty;
... but I need to expose these properties to other (not related to w762>) objects in a common way. Ideally, I could expose them using a method, for example:
public String getPropertyValue(String key) { @Value("${" + key + "}") String value; return value; }
... but obviously I cannot use the @Value annotation in this context. Is there a way to access properties loaded using Spring from example.prefs at runtime using keys, for example:
public String getPropertyValue(String key) { return SomeSpringContextOrEnvironmentObject.getValue(key); }
java spring properties-file
Doches
source share