tags:

views:

122

answers:

1

i'm reading liferay source code and found out that 2 xml files using same bean-id. will all the properties merge together if using this way?

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>
+3  A: 

No, the Spring context will select one bean definition over the other. Which one it chooses depends on what order the files are fed into the context during initialization.

Logging should indicate that one bean definition is overriding another.

skaffman
Check out this Spring fix to avoid the "hunt the log file entry" game: http://jira.springframework.org/browse/SPR-4374
hbunny