Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij, says a file doesn't exist in web-inf, but it does

I installed Intellij yesterday to see how it compared to Eclipse.

I've created a Maven project, imported the dependencies for Spring and setup everything I think I need to test the application runs.

The issue I have is that in the web.xml file it's marking one of the servlet configuration files as not found, when it does exist. I'm guessing this has something to do with the mapping of the web-inf folder, but I can't figure it out in Intellij

Here's the content of the web.xml file

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

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

I'm including a screenshot of my folder structure too.

enter image description here

The path was mapping fine, but then I change the artifact to be a war instead of exploded, and it seems to have broken something.

The error message on application run is;

IOException parsing XML document from ServletContext resource [/WEB-INF/spring/dispatcher-servlet.xml]; nested exception is java.io.FileNotFoundException:

Any assistance would be appreciated.

like image 751
SheppardDigital Avatar asked Dec 08 '22 00:12

SheppardDigital


2 Answers

Probably this one will make it clearer:

  1. project structure:

    project structure

  2. set webapp folder as resources:

    set webapp folder as resources

like image 64
surga Avatar answered Dec 11 '22 10:12

surga


I managed to fix this.

The web-inf folder was set as / in the paths section.

File > Project Structure Choose Modules Select Web Under Web Resources Directories, map the 'web' folder to '/'

like image 38
SheppardDigital Avatar answered Dec 11 '22 10:12

SheppardDigital