问题
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>
回答1:
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.
来源:https://stackoverflow.com/questions/1443070/same-bean-id-on-different-xml-file-will-it-merge