How can I pass vm args
(java -Dport = 5) to the application context
?
I want to configure the port dynamically by the user, using the application context
.
How can I pass vm args
(java -Dport = 5) to the application context
?
I want to configure the port dynamically by the user, using the application 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 –Dport=5, which can be accessed as
<bean class="com.testing.test.MyClass">
<property name="myProperty" value="${port}"></property>
</bean>
I think There is only one way in spring using injection. and get the property value from any property file