Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Properties String in Spring XML configuration file

Is there a way to set a property of a bean in a Spring configuration file to that of a string read from a Properties file?

e.g.

<bean id="...." class="....">
    <property name="loginURL">GET_THIS_VALUE_FROM_'ENV.PROPERTIES'_FILE</property>
</bean>
like image 303
NRaf Avatar asked Dec 27 '22 19:12

NRaf


1 Answers

You should be able to use a PropertyPlaceHolderConfigurer to load a properties file, and then refer to the properties using an Spring-EL expression -

<context:property-placeholder location="classpath:custom.properties"/>

<bean id="...." class="....">
    <property name="loginURL">${propname}</property>
</bean>
like image 50
Biju Kunjummen Avatar answered Dec 31 '22 11:12

Biju Kunjummen