当前位置: 代码迷 >> Web前端 >> web中运用beanRefContext.xml的方式加载spring
  详细解决方案

web中运用beanRefContext.xml的方式加载spring

热度:169   发布时间:2012-08-15 16:57:17.0
web中使用beanRefContext.xml的方式加载spring

步骤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>

?

?

。。

  相关解决方案