开发者

Using Properties String in Spring XML configuration file

开发者 https://www.devze.com 2023-03-12 20:14 出处:网络
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?

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>


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消