2011-12-19 8 views

risposta

9

La mia soluzione

<context:property-placeholder location="classpath*:*.properties,file:/some/other/path/*.properties" /> 
+0

Questo funziona per il segnaposto che avete nel vostro file di configurazione $ {} some.props, ma che non funziona con @Value ("# {properties}") nel tuo bean, per usare quella soluzione che @Alexei Osipov funziona, nel caso qualcuno abbia bisogno di quell'informazione – Koitoer

3

util: proprietà sembra supportare file di solo 1 proprietà (reference). Potresti voler usare la configurazione suggerita da @peperg.

+0

grazie per la risposta – Anshul

13

In realtà <util:properties> è solo tag conveniente per org.springframework.beans.factory.config.PropertiesFactoryBean. E PropertiesFactoryBean supporta più posizioni.

quindi è possibile creare di fagioli con Properties questo modo:

<bean id="myProps" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
     <property name="locations"> 
      <list> 
       <value>classpath:myprops-common.properties</value> 
       <value>classpath:myprops-override.properties</value> 
       <value>classpath:some-more-props-here.properties</value> 
      </list> 
     </property> 
    </bean> 
+0

Questa dovrebbe essere la risposta accettata! – JonyD

Problemi correlati