4
有没有办法将Spring配置文件中的bean的属性设置为从属性文件中读取的字符串的属性?在Spring XML配置文件中使用属性字符串
例如
<bean id="...." class="....">
<property name="loginURL">GET_THIS_VALUE_FROM_'ENV.PROPERTIES'_FILE</property>
</bean>
有没有办法将Spring配置文件中的bean的属性设置为从属性文件中读取的字符串的属性?在Spring XML配置文件中使用属性字符串
例如
<bean id="...." class="....">
<property name="loginURL">GET_THIS_VALUE_FROM_'ENV.PROPERTIES'_FILE</property>
</bean>
您应该能够使用PropertyPlaceHolderConfigurer加载属性文件,然后使用Spring的EL表达式来引用属性 -
<context:property-placeholder location="classpath:custom.properties"/>
<bean id="...." class="....">
<property name="loginURL">${propname}</property>
</bean>