In a standard Spring application, a PropertyPlaceholderConfigurer may be defined, which will load one or more property files. The values defined in the files will then be visible to the rest of the application, both in XML ("${}"
) and Java (@Value
).
Is there a way, once a context has been loaded, to get such a property value from the context itsef, in the similar way that a bean can be retrieved (ctx.getBean("bean-name")
) ?
I tried the following, but it does not work:
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load("classpath:META-INF/spring/spring-context.xml");
ctx.refresh();
ctx.start();
ctx.getEnvironment().getProperty("key-name")); // RETURNS NULL
Thanks