开发者

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>


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜