
您有两种选择:
进口包括在<import resource="classpath:config/spring/that-other-xml-conf.xml"/><bean id="yourCoolBean" > <property name="anotherBean" ref="thatOtherBean"/></bean>
ApplicationContext建筑中
ApplicationContext创建它们时,将两个文件都放入您的文件中=>则无需导入。
例如,如果您在测试期间需要它:
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration({ "classpath:meta-INF/conf/spring/this-xml-conf.xml", "classpath:meta-INF/conf/spring/that-other-xml-conf.xml" })public class CleverMoneyMakingBusinessServiceIntegrationTest {...}如果它是一个网络应用程序,则可以在中进行
web.xml:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/conf/spring/this-xml-conf.xml</param-value> <param-value>WEB-INF/conf/spring/that-other-xml-conf.xml</param-value></context-param><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
如果它是独立的应用程序,库等,则应将其加载
ApplicationContext为:
new ClassPathXmlApplicationContext( new String[] { "classpath:meta-INF/conf/spring/this-xml-conf.xml", "classpath:meta-INF/conf/spring/that-other-xml-conf.xml" } );欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)