Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

前端 未结 2 465
清酒与你
清酒与你 2020-12-03 02:27

Ok, I am 500th user asking this question, I read many answers but still having no luck.

parent module pom contains:


    

        
相关标签:
2条回答
  • 2020-12-03 03:10

    Update: This will create a second context same as in applicationContext.xml

    or you can add this code snippet to your web.xml

    <servlet>
        <servlet-name>spring-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>classpath:applicationContext.xml</param-value>
            </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    

    instead of

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    0 讨论(0)
  • 2020-12-03 03:18

    ContextLoaderListener has its own context which is shared by all servlets and filters. By default it will search /WEB-INF/applicationContext.xml

    You can customize this by using

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/somewhere-else/root-context.xml</param-value>
    </context-param>
    

    on web.xml, or remove this listener if you don't need one.

    0 讨论(0)
提交回复
热议问题