Skip to content
Advertisement

Java servlet web.xml file cannot resolve the class in the tag in IntelliJ

I am writing a simple web service and have put my web.xml file in the WEB-INF folder. For some reason everything in the servlet-class tag is coming up as “cannot resolve class MyServlet”. The class MyServlet is in the src folder under root directory. I cannot figure out why as to why this is happening.

JavaScript

Advertisement

Answer

I needed to mark my src folder as “Source Root” in IntelliJ. This can be done by right clicking the folder -> mark directory as. After that my class files actually became linkable.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement