学习写代码呀

导航

BeanFactory not initialized or already closed - call 'refresh' before access

BeanFactory not initialized or already closed - call 'refresh' before access

web项目默认会去寻找spring-mvc.xml文件,没有配置就会报错。

改成:

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

<servlet>
        <servlet-name>dispatchServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>classpath:spring-mvc.xml</param-value>
      </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatchServlet</servlet-name>
      <url-pattern>*.do</url-pattern>
    </servlet-mapping>

posted on 2020-10-20 09:45  学习写代码呀  阅读(870)  评论(0编辑  收藏  举报