VM arguments in spring context

In case you trying to access the VM arguments in spring application context, then just add the below bean definition in context file:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="ignoreUnresolvablePlaceholders" value="true"></property>
</bean>

And access the VM args as ${vm_property}, e.g if you passed the –Dfoo=bar, which can be access as,
<bean class="com.company.test.MyClazz">
      <property name="myProperty" value="${foo}"></property>
</bean>

Comments

Popular Posts