I currently work on a web application based on Spring 3.1.0.M1, annotations based, and I have a problem with resolving property placeholders in one specific place of my appl
One option is to add a PropertySource
(here MapPropertySource
to exemplify an in-memory configuration) to a ConfigurableEnvironment
and ask it to resolve properties for you.
public class Foo {
@Autowired
private ConfigurableEnvironment env;
@PostConstruct
public void setup() {
env.getPropertySources()
.addFirst(new MapPropertySource("my-propertysource",
ImmutableMap.of("your.property.name", "the value")));
env.resolvePlaceholders("your.property.name");
}
}
Optionally annotate the Foo
class with @Configuration
to enjoy the power of programmatic configuration in favor of XML
.