Maven encounters Failonmissingwebxml about problem Resolution: Web. XML is missing and was set to True

Source: Internet
Author: User

When you create a project using MAVEN, there are sometimes failonmissingwebxml errors in the Pom.xml War where the error message is: Web. XML is missing and <failOnMissingWebXml> is set to true;

The reason for this is that the Web. xml file must be added to the MAVEN project, however, the XML file has become dispensable in the recent application development. However, Maven has not yet followed this change, so we have two ways to solve this problem:


Method One:

If there is no web. XML in the project, add a Web. XML to the project, refresh the project, there should be no error, if your project has Web. XML under/src/main/webapp/web-inf, but still report the error, it takes two steps:

1) Right-click the project, open the Properties dialog, click the Deployment assembly option, add a folder to the right, and save the settings

2) Click Project->clean above Eclispe to clean up this project

The Web. Xml reads as follows:

<?xml version= "1.0" encoding= "UTF-8"?> <web-app
	xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "
		xmlns=" Http://java.sun.com/xml/ns/javaee "xmlns:web=" http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "
		xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
		id= "webapp_id" version= "2.5" >
		<welcome-file-list>
			<welcome-file>index.html</ welcome-file>
			<welcome-file>index.htm</welcome-file>
			<welcome-file>index.jsp</ welcome-file>
			<welcome-file>default.html</welcome-file>
			<welcome-file>default.htm </welcome-file>
			<welcome-file>default.jsp</welcome-file>
		</welcome-file-list >
</web-app>

However, the method does not seem to solve the problem, so continue to look down.


Method Two:

Just deal with the problem of <failOnMissingWebXml>false</failOnMissingWebXml> being set to false. That is, add the following configuration to the Pom.xml:

<build>  
    <plugins>  
        <plugin>  
            <groupid>org.apache.maven.plugins</groupid >  
            <artifactId>maven-war-plugin</artifactId>  
            <version>2.3</version>  
            < configuration>  
                <failOnMissingWebXml>false</failOnMissingWebXml>  
            </configuration>  
        </plugin>  
    </plugins>  
</build>
As shown in figure:


The problem has been resolved. The advantage of this is that we do not have to be a useless web. xml file in the project life. There is no problem with the missing Web. xml file in maven where the update version (from which version I do not know ~ ~) already exists.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.