步骤1、
将beanRefContext.xml
放在classpath
目录下,并在其中的businessBeanFactory中加载其他配置文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="businessBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext"> <constructor-arg> <list> <value>applicationContext-datasource.xml</value> <value>applicationContext-dao.xml</value> <value>applicationContext-serviceImpl.xml</value> </list> </constructor-arg> </bean> </beans>?
步骤2、web.xml中配置加载
<context-param> <param-name>locatorFactorySelector</param-name> <param-value>classpath:beanRefContext.xml</param-value> </context-param> <context-param> <param-name>parentContextKey</param-name> <param-value>businessBeanFactory</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
?
?
。。