加载 bean.xml 的几种方式 (java or web project)

1. java project

ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:bean1.xml","classpath:bean2.xml");

2. web project

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/beans.xml</param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

3. Test

org.springframework spring-test

原文地址:https://www.cnblogs.com/zno2/p/4692134.html