首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

多个spring,applicationContext文件,在一个文件中,如何引用其他文件中的bean

2012-01-10 
多个spring,applicationContext文件,在一个文件中,怎么引用其他文件中的bean比如一个主的applicationConte

多个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>

热点排行