Closed spring-projects-issues closed 12 years ago
Juergen Hoeller commented
This is actually not a bug but rather a lacking feature: PropertyPlaceholderConfigurer only resolves placeholders on bean definitions other than its own. If you specify a placeholder on a value within the PropertyPlaceholderConfigurer definition itself, you got a chicken-and-egg problem: The PropertyPlaceholderConfigurer cannot run because it cannot initialize itself.
What's really kicking in here to resolve such an "early" placeholder is Spring's SystemPropertyUtils class, which resolves them against system property values. What I've added there now is an automatic fallback to system environment variables, simply ignoring the placeholder if system environment access fails for it (which is the case on quite a few JVMs/platforms - system environment access is not encouraged on the Java platform).
Juergen
Alex Wei commented
But not all property placeholders in the definition of a PropertyPlaceholderConfigurer can be resolved against system property values, such as "fileEncoding", which is quite painful for me as the the property file I load is on IBM mainframe using EBCDIC while my development is on Windows using ASCII.
Akmal Sarhan opened SPR-1893 and commented
the following snippet does not work \
\\true\ \
\\SYSTEM_PROPERTIES_MODE_FALLBACK\ \
if SERVER_MODE is a system env. the solution is to change org.springframework.util.SystemPropertyUtils
to try to resolve the placeholder via: ... String propVal = System.getProperty(placeholder); if (propVal == null) propVal = System.getenv(placeholder); ...
Affects: 2.0 M3
Issue Links:
6542 Resource location placeholders not resolved against system environment variables ("duplicates")