日期:2014-05-17  浏览次数:20698 次

多个spring,applicationContext文件,在一个文件中,怎么引用其他文件中的bean
比如一个主的applicationContext.xml文件,一个子的applicationContext-cxf.xml文件,现在子文件中要调用主文件中的
<bean id="sqlmapclient"></bean>这个bean,应该怎么处理?

spring的多文件已经在wen.xml中进行配置了,如下
<param-value>
classpath*:applicationContext*.xml,
classpath*:com/**/applicationContext*.xml,
</param-value>

------解决方案--------------------
<bean class=xxx>
<property name=xx ref=sqlmapclient/>
------解决方案--------------------
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
------解决方案--------------------
直接使用呀,
不要感觉文件现在是分开的,但是在spring启动的时候,会将所有的spring文件合并的。因此不要存在这种感觉,不在你现在的XXXX-cxf.xml中。
 使用就是直接使用就可以了
<bean id="" class="">
<property name="xxxx" ref="sqlclinet"/>
</bean>