The idea adds the Web. XML configuration file to an issue that was not found in the Web. xml file that was encountered in Tomcat startup

Source: Internet
Author: User

1. How to add a configuration file for Web. XML to the war project in idea

The idea of creating a war project through Maven did not specify a folder that was WebApp caused the project to be created without webapp. In fact, the War project is under the "Project name/src/main" directory.

Just create a webapp/web-inf/web.xml under this project.

2, if you do not put the Web. XML in "project name/src/main/webapp/web-inf/web.xml", then Tomcat will start error:

MAVEN Package Error message: "Error assembling War:webxml attribute is required" or pre-existing web-inf/web.xml if executing in update mo De


Reason:

The default webroot for MAVEN packaged Web projects is at Src\main\webapp. If the Web. XML is not found in this directory, the above exception is thrown.

WORKAROUND: You need to add the <webResources> configuration to the Pom.xml as follows:

1   <plugin> 2                 <groupId>org.apache.maven.plugins</groupId> 3                 < Artifactid>maven-war-plugin</artifactid> 4                 <version>2.1.1</version> 5                 <configuration> 6  7                     <webxml>src\webapp\web-inf\web.xml</webxml > 8  9                 </configuration>             </plugin>

The position of the <webXml> here is relative to the path of the project, and the parent is the directory of the project name:

The path to Web. XML is

Project Name \src\webapp\web-inf\web.xml

Add the Web. XML configuration file to idea and the Web. xml file encountered in Tomcat startup is not found

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.