I have a PropertyPlaceholderConfigurer
that loads multiple properties files. I want to inject the merged properties map into a Spring Bean via config XML.
Can I do that and how?
Join Stack Overflow to learn, share knowledge, and build your career.
I have a PropertyPlaceholderConfigurer
that loads multiple properties files. I want to inject the merged properties map into a Spring Bean via config XML.
Can I do that and how?
You could just create a properties bean and use that for your PropertyPlaceholderConfigurer
and your Config
bean:
<bean id="myProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:default.properties</value>
<value>classpath:someother.properties</value>
</list>
</property>
</bean>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties" ref="myProperties" />
</bean>
<bean id="myConfigBean" class="my.pkg.Config">
<constructor-arg ref="myProperties" />
</bean>