2009-09-18 8 views
7

sto leggendo il codice sorgente di liferay e ho scoperto che 2 file xml utilizzano lo stesso bean-id. tutte le proprietà si uniranno insieme se si utilizza in questo modo?identico ID bean su file xml diverso, si unirà?

dynamic-data-spring 
---------------------- 
    <bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"> 
     <property name="targetDataSource"> 
      <bean class="org.springframework.aop.framework.ProxyFactoryBean"> 
       <property name="targetSource" ref="dynamicDataSourceTargetSource" /> 
      </bean> 
     </property> 
    </bean> 

infrastructure-spring.xml 
---------------------- 
<bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"> 
     <property name="targetDataSource"> 
      <bean class="com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean"> 
       <property name="propertyPrefix" value="jdbc.default." /> 
      </bean> 
     </property> 
    </bean> 

risposta

7

No, il contesto Spring selezionerà una definizione di bean rispetto all'altra. Quale sceglie dipende da quale ordine i file vengono inseriti nel contesto durante l'inizializzazione.

La registrazione dovrebbe indicare che una definizione di bean sta sovrascrivendo un'altra.

+1

Dai un'occhiata a questa correzione di primavera per evitare il gioco "hunt the log file entry": http://jira.springframework.org/browse/SPR-4374 – SteveD