spring - context:property-placeholder how to reference the property bean -
we have existing property loader configuration in our spring context
<bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <util:list> <value>hedging-service.properties</value> </util:list> </property> </bean> <!--hedging properties bean can injected other beans--> <util:properties id="hedgingproperties" location="classpath:hedging-service.properties"/>
and there bean references hedgingproperties
bean
<bean id="mailprocessor" class="a.b.c.mailprocessor"> <property name="properties" ref="hedgingproperties"/> ... </bean>
i'm refactoring context load multiple property files , avoid duplicate definition of properties. first attempt use bean in place of 2 above
<context:property-placeholder location="classpath:hedging-service-core.properties,classpath:hedging-service.properties,classpath:icon.properties"/>
but how can retain alias or reference hedgingproperties
bean when use context:property-placeholder
?
the answer mixture context:property-placeholder
, util:properties
<util:properties id="hedgingproperties" location="classpath:hedging-service.properties"/> <context:property-placeholder properties-ref="hedgingproperties" /> <bean id="mailprocessor" class="a.b.c.mailprocessor"> <property name="properties" ref="hedgingproperties"/> ... </bean>
Comments
Post a Comment