I want to access some property value passed from JVM in Spring’s applicationContext.xml. One way I know to achieve this is by #{systemProperties.myProperty} for some -DmyProperty=xyz according to Spring’s Expression Language feature.
But I am interested in having a default value for each such property that I assign through JVM, in case the user doesn’t set the value from JVM options of the server. How can I achieve this in any context xml file for Spring? Please help.
You can make a bean which takes a map parameter from context with default values and initializes system properties
.
B1 definition in the context should be before any bean using
#{systemProperties.myProperty}so that properties are initialized firstUPDATE
That was about overriding system properties. But if you only need to override Spring placeholders like here
it’s enough to set property-placeholder’s local-override attr to “true”