Open In App

How to Resolve WEB xml is missing and failOnMissingWebXml is set to true in Eclipse/STS?

Last Updated : 28 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Eclipse/STS IDE is generally used to develop Spring applications and what happens is whenever we are creating a simple Maven project and if the web.xml is missing or you have deleted that file then you may encounter this problem inside the pom.xml file corresponding to which do refer to the below image as follows: 

 

Now we are going to discuss how can we resolve this error via discussing two ways to fix this error which are as follows:

  1. Modifying the pom.xml file.
  2. Generating Deployment Descriptor Stub.

Solution 1: Modification in the pom.xml file

The simple and best solution for this problem is, just write the following line of code inside the <properties> tag something like this.

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

And this will resolve the error. Refer to the below image. 

 

Note: We can see the error has been gone. 

Solution 2: Generate Deployment Descriptor Stub

The other solution is, click on your project > right-click > Java EE Tools > Generate Deployment Descriptor Stub as shown in the below image. 

 

And this will generate the web.xml file inside the WEB-INF folder with some pre-defined code as shown in the below image. And it will also resolve the error. 

 

Tip: Now heeks you must be wondering which way is better so straight forward answer is that Solution 1 is a better solution than adding an empty web.xml because this way the final product stays clean, we are just changing the build parameters.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads