same bean id on different xml file, will it merge?

一笑奈何 提交于 2019-12-08 17:42:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!