只要在web.xml中加入这句
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
就会报错java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext。项目无法启动。

解决方案 »

  1.   

    <context-param>
            <param-name>contextConfigLocation</param-name>
            <!--<param-value>/WEB-INF/applicationContext.xml</param-value>-->
            <param-value>classpath:applicationContext*.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
            <!--org.springframework.web.context.ContextLoaderServlet -->
        </listener>
        <!--contextConfigLocation在 ContextLoaderListener类中的默认值是 /WEB-INF/applicationContext.xml-->
      

  2.   

    应该是读不到contextConfigLocation参数,报的错误。
      

  3.   

    不是额,我配了applicationContext.xml额。
      

  4.   

    applicationContext.xml确定是在/WEB-INF/下?
      

  5.   

    在src下配的路径<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
      </context-param>
      

  6.   

    围观一下~~也有可能和spring版本有关  
      

  7.   

    我估计是 BeanFactory 代码写的有问题,看一下代码吧。