There is a property file with the following contents

client.properties file:

  id=1 name=John Smith greeting=hello there! 

I use it in the definition of bins:

  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:client.properties</value> </list> </property> </bean> <bean class="Client" id="client"> <constructor-arg value="${id}"/> <constructor-arg value="${name}"/> </bean> 

Now I want to connect another 1 property file with the same nags, but different values

annotatedClient.properties :

 id=2 name=Vasiliy 

How to distinguish between them?

do as follows:

  <property name="locations"> <list> <value>classpath:client.properties</value> <value>classpath:annotaitedClient.properties</value> </list> </property> 

so is exeption (

Could not resolve placeholder 'client.id' in string value "$ {client.id}"

):

  <bean class="Client" id="client"> <constructor-arg value="${client.id}"/> <constructor-arg value="${client.name}"/> <property name="greeting" value="${greeting}"/> </bean> 

only annotaitedClent.properties file is read annotaitedClent.properties :

  <bean class="Client" id="client"> <constructor-arg value="${id}"/> <constructor-arg value="${name}"/> <property name="greeting" value="${greeting}"/> </bean> 

    1 answer 1

    Try this:

     <util:properties id="clientProps" location="classpath:client.properties"></util:properties> <util:properties id="annotaitedClientProps" location="classpath:annotaitedClient.properties"></util:properties> <bean id="allProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="propertiesArray"> <list> <ref bean="clientProps"></ref> <ref bean="annotaitedClientProps"></ref> </list> </property> </bean> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="properties" ref="allProperties"></property> </bean>