Spring MVC Tutorial
Core Spring MVC
Spring MVC - Annotation
Spring MVC - Form Handling
Spring MVC with JSTL
Spring MVC with REST API
Spring MVC with Database
The error message "WEB xml is missing and failOnMissingWebXml
is set to true" typically occurs when you're building a Maven-based web project using an older webapp archetype, and your project is missing the web.xml
file in the WEB-INF
directory. However, in modern Servlet 3.0+ based applications, the web.xml
file is no longer mandatory.
Here's how you can resolve this error in Eclipse or Spring Tool Suite (STS):
web.xml
file (Traditional way):If you believe that you really need a web.xml
file:
New -> Other
.General -> File
.src/main/webapp/WEB-INF/
and the file name to web.xml
.web.xml
with the necessary content.maven-war-plugin
Configuration (Modern way):If you don't want or need a web.xml
:
pom.xml
file.maven-war-plugin
configuration to include the failOnMissingWebXml
setting:<build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.3.1</version> <!-- Use the latest version here --> <configuration> <!-- Ignore the missing web.xml file --> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> ... </plugins> </build>
pom.xml
.Maven -> Update Project
.Now, when you build your project, Maven should not complain about the missing web.xml
file.
If you're using a modern version of Spring Boot, you generally don't need a web.xml
file. Spring Boot applications are typically configured using Java config and annotations. The maven-war-plugin
configuration method is preferred in this case.